<commit_before>remoteStorage.js
================

This is a library for adding remoteStorage support to your client-side app. See http://unhosted-tutorial.galfert.5apps.com/ for example usage.

Version and license
=======
This is version 0.4.5 of the library, and you can use it under AGPL or MIT license - whatever floats your boat. Pull requests are very welcome (if you're not on github you can email them to michiel at unhosted.org).

Code example
=========

    require(['./js/remoteStorage'], function(remoteStorage) {
      var bearerToken = remoteStorage.receiveToken();
      if(!bearerToken) {//when you first hit the page
        remoteStorage.getStorageInfo('<EMAIL>', function(err, storageInfo) {
          localStorage.storageInfo=JSON.stringify(storageInfo);
          window.location = remoteStorage.createOAuthAddress(storageInfo, ['sandwiches'], window.location.href);
        });
      } else {//after you come back from the OAuth dance
        var client = remoteStorage.createClient(JSON.parse(localStorage.storageInfo), 'sandwiches', bearerToken);
        client.put('foo', 'bar', function(err) {
          client.get('foo', function(err, data) {
            alert(data);
          });
        });
      }
    });


Function reference
=======

remoteStorage.getStorageInfo(userAddress, callback)
-------
<commit_msg>made code example simpler<commit_after>remoteStorage.js
================

This is a library for adding remoteStorage support to your client-side app. See http://unhosted-tutorial.galfert.5apps.com/ for example usage.

Version and license
=======
This is version 0.4.5 of the library, and you can use it under AGPL or MIT license - whatever floats your boat. Pull requests are very welcome (if you're not on github you can email them to michiel at unhosted.org).

Code example
=========

    require(['./js/remoteStorage'], function(remoteStorage) {
      remoteStorage.getStorageInfo('<EMAIL>', function(err, storageInfo) {
        var token = remoteStorage.receiveToken();
        if(token) {
          //we can access the 'sandwiches' category on the remoteStorage of <EMAIL>:
          var client = remoteStorage.createClient(storageInfo, 'sandwiches', bearerToken);
          client.put('foo', 'bar', function(err) {
            client.get('foo', function(err, data) {
              client.delete('foo', function(err) {
              });
            });
          });
        } else {
          //get an access token for 'sandwiches' by dancing OAuth with the remoteStorage of <EMAIL>:
          window.location = remoteStorage.createOAuthAddress(storageInfo, ['sandwiches'], window.location.href);
        }
      });
    });


Function reference
=======

remoteStorage.getStorageInfo(userAddress, callback)
-------

{'fraction_non_alphanumeric': 0.13446901051105473, 'fraction_numerical': 0.002899601304820587, 'mean_word_length': 3.1818181818181817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6754210', 'n_tokens_mistral': 753, 'n_tokens_neox': 724, 'n_words': 228}