Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fh-js-sdk

Package Overview
Dependencies
Maintainers
10
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fh-js-sdk - npm Package Compare versions

Comparing version 3.1.0-dev to 4.0.0-beta

3

CHANGELOG.md
# Changelog - FeedHenry Javascript SDK
## 3.1.0 - 2019-04-15
## 4.0.0 - 2019-04-15
### Change
- Upgrade version of fh-sync-js from 1.3.2 to 1.4.0
- Update lawnchair lib files from fh-sync-js version 1.4.0

@@ -7,0 +8,0 @@ ## 3.0.12 - 2018-11-30

@@ -7,3 +7,3 @@ /**

*/
var Lawnchair = function (options, callback) {
var Lawnchair = module.exports = function (options, callback) {
// ensure Lawnchair was called as a constructor

@@ -89,3 +89,3 @@ if (!(this instanceof Lawnchair)) return new Lawnchair(options, callback);

// methods required to implement a lawnchair adapter
var implementing = 'adapter valid init keys save batch get exists all remove nuke'.split(' ')
var implementing = 'adapter valid init keys close save batch get exists all remove nuke'.split(' ')
, indexOf = this.prototype.indexOf

@@ -168,2 +168,10 @@ // mix in the adapter

};
require('./lawnchairHtml5FileSystem')(Lawnchair)
require('./lawnchairIndexDbAdapter')(Lawnchair)
require('./lawnchairLocalStorageAdapter')(Lawnchair)
require('./lawnchairMemoryAdapter')(Lawnchair)
require('./lawnchairTitanium')(Lawnchair)
require('./lawnchairWebkitSqlAdapter')(Lawnchair)
require('./lawnchairWindowNameStorageAdapter')(Lawnchair)
// window.name code courtesy Remy Sharp: http://24ways.org/2009/breaking-out-the-edges-of-the-browser

@@ -299,212 +307,214 @@ Lawnchair.adapter('window-name', (function() {

})())
/**
* dom storage adapter
* ===
* - originally authored by Joseph Pecoraro
*
*/
//
// TODO does it make sense to be chainable all over the place?
// chainable: nuke, remove, all, get, save, all
// not chainable: valid, keys
//
Lawnchair.adapter('dom', (function() {
var storage = null;
try{
storage = window.localStorage;
}catch(e){
module.exports = function (Lawnchair) {
/**
* dom storage adapter
* ===
* - originally authored by Joseph Pecoraro
*
*/
//
// TODO does it make sense to be chainable all over the place?
// chainable: nuke, remove, all, get, save, all
// not chainable: valid, keys
//
Lawnchair.adapter('dom', (function() {
var storage = null;
try{
storage = window.localStorage;
}catch(e){
}
// the indexer is an encapsulation of the helpers needed to keep an ordered index of the keys
var indexer = function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
// the indexer is an encapsulation of the helpers needed to keep an ordered index of the keys
var indexer = function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
return JSON.parse(storage.getItem(this.key))
},
// adds a key to the index
add: function (key) {
var a = this.all()
a.push(key)
storage.setItem(this.key, JSON.stringify(a))
},
// deletes a key from the index
del: function (key) {
var a = this.all(), r = []
// FIXME this is crazy inefficient but I'm in a strata meeting and half concentrating
for (var i = 0, l = a.length; i < l; i++) {
if (a[i] != key) r.push(a[i])
}
storage.setItem(this.key, JSON.stringify(r))
},
// returns index for a key
find: function (key) {
var a = this.all()
for (var i = 0, l = a.length; i < l; i++) {
if (key === a[i]) return i
}
return false
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
return JSON.parse(storage.getItem(this.key))
},
// adds a key to the index
add: function (key) {
var a = this.all()
a.push(key)
storage.setItem(this.key, JSON.stringify(a))
},
// deletes a key from the index
del: function (key) {
var a = this.all(), r = []
// FIXME this is crazy inefficient but I'm in a strata meeting and half concentrating
for (var i = 0, l = a.length; i < l; i++) {
if (a[i] != key) r.push(a[i])
}
storage.setItem(this.key, JSON.stringify(r))
},
// returns index for a key
find: function (key) {
var a = this.all()
for (var i = 0, l = a.length; i < l; i++) {
if (key === a[i]) return i
}
return false
}
}
}
// adapter api
return {
// adapter api
return {
// ensure we are in an env with localStorage
valid: function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.setItem(value, value)
} catch (e) {
success = false
}
storage.removeItem(value)
return success
}()
},
// ensure we are in an env with localStorage
valid: function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.setItem(value, value)
} catch (e) {
success = false
}
storage.removeItem(value)
return success
}()
},
init: function (options, callback) {
this.indexer = indexer(this.name)
if (callback) this.fn(this.name, callback).call(this, this)
},
init: function (options, callback) {
this.indexer = indexer(this.name)
if (callback) this.fn(this.name, callback).call(this, this)
},
save: function (obj, callback) {
var key = obj.key ? this.name + '.' + obj.key : this.name + '.' + this.uuid()
// now we kil the key and use it in the store colleciton
delete obj.key;
storage.setItem(key, JSON.stringify(obj))
// if the key is not in the index push it on
if (this.indexer.find(key) === false) this.indexer.add(key)
obj.key = key.slice(this.name.length + 1)
if (callback) {
this.lambda(callback).call(this, obj)
}
return this
},
save: function (obj, callback) {
var key = obj.key ? this.name + '.' + obj.key : this.name + '.' + this.uuid()
// now we kil the key and use it in the store colleciton
delete obj.key;
storage.setItem(key, JSON.stringify(obj))
// if the key is not in the index push it on
if (this.indexer.find(key) === false) this.indexer.add(key)
obj.key = key.slice(this.name.length + 1)
if (callback) {
this.lambda(callback).call(this, obj)
}
return this
},
batch: function (ary, callback) {
var saved = []
// not particularily efficient but this is more for sqlite situations
for (var i = 0, l = ary.length; i < l; i++) {
this.save(ary[i], function(r){
saved.push(r)
})
}
if (callback) this.lambda(callback).call(this, saved)
return this
},
batch: function (ary, callback) {
var saved = []
// not particularily efficient but this is more for sqlite situations
for (var i = 0, l = ary.length; i < l; i++) {
this.save(ary[i], function(r){
saved.push(r)
})
}
if (callback) this.lambda(callback).call(this, saved)
return this
},
// accepts [options], callback
keys: function(callback) {
if (callback) {
var name = this.name
var indices = this.indexer.all();
var keys = [];
//Checking for the support of map.
if(Array.prototype.map) {
keys = indices.map(function(r){ return r.replace(name + '.', '') })
} else {
for (var key in indices) {
keys.push(key.replace(name + '.', ''));
// accepts [options], callback
keys: function(callback) {
if (callback) {
var name = this.name
var indices = this.indexer.all();
var keys = [];
//Checking for the support of map.
if(Array.prototype.map) {
keys = indices.map(function(r){ return r.replace(name + '.', '') })
} else {
for (var key in indices) {
keys.push(key.replace(name + '.', ''));
}
}
this.fn('keys', callback).call(this, keys)
}
this.fn('keys', callback).call(this, keys)
}
return this // TODO options for limit/offset, return promise
},
return this // TODO options for limit/offset, return promise
},
get: function (key, callback) {
if (this.isArray(key)) {
var r = []
for (var i = 0, l = key.length; i < l; i++) {
var k = this.name + '.' + key[i]
var obj = storage.getItem(k)
get: function (key, callback) {
if (this.isArray(key)) {
var r = []
for (var i = 0, l = key.length; i < l; i++) {
var k = this.name + '.' + key[i]
var obj = storage.getItem(k)
if (obj) {
obj = JSON.parse(obj)
obj.key = key[i]
}
r.push(obj)
}
if (callback) this.lambda(callback).call(this, r)
} else {
var k = this.name + '.' + key
var obj = storage.getItem(k)
if (obj) {
obj = JSON.parse(obj)
obj.key = key[i]
obj.key = key
}
r.push(obj)
if (callback) this.lambda(callback).call(this, obj)
}
if (callback) this.lambda(callback).call(this, r)
} else {
var k = this.name + '.' + key
var obj = storage.getItem(k)
if (obj) {
obj = JSON.parse(obj)
obj.key = key
}
if (callback) this.lambda(callback).call(this, obj)
}
return this
},
return this
},
exists: function (key, cb) {
var exists = this.indexer.find(this.name+'.'+key) === false ? false : true ;
this.lambda(cb).call(this, exists);
return this;
},
// NOTE adapters cannot set this.__results but plugins do
// this probably should be reviewed
all: function (callback) {
var idx = this.indexer.all()
, r = []
, o
, k
for (var i = 0, l = idx.length; i < l; i++) {
k = idx[i] //v
o = JSON.parse(storage.getItem(k))
o.key = k.replace(this.name + '.', '')
r.push(o)
}
if (callback) this.fn(this.name, callback).call(this, r)
return this
},
remove: function (keyOrArray, callback) {
var self = this;
if (this.isArray(keyOrArray)) {
// batch remove
var i, done = keyOrArray.length;
var removeOne = function(i) {
self.remove(keyOrArray[i], function() {
if ((--done) > 0) { return; }
if (callback) {
self.lambda(callback).call(self);
}
});
};
for (i=0; i < keyOrArray.length; i++)
removeOne(i);
exists: function (key, cb) {
var exists = this.indexer.find(this.name+'.'+key) === false ? false : true ;
this.lambda(cb).call(this, exists);
return this;
}
var key = this.name + '.' +
((keyOrArray.key) ? keyOrArray.key : keyOrArray)
this.indexer.del(key)
storage.removeItem(key)
if (callback) this.lambda(callback).call(this)
return this
},
},
// NOTE adapters cannot set this.__results but plugins do
// this probably should be reviewed
all: function (callback) {
var idx = this.indexer.all()
, r = []
, o
, k
for (var i = 0, l = idx.length; i < l; i++) {
k = idx[i] //v
o = JSON.parse(storage.getItem(k))
o.key = k.replace(this.name + '.', '')
r.push(o)
}
if (callback) this.fn(this.name, callback).call(this, r)
return this
},
nuke: function (callback) {
this.all(function(r) {
for (var i = 0, l = r.length; i < l; i++) {
this.remove(r[i]);
remove: function (keyOrArray, callback) {
var self = this;
if (this.isArray(keyOrArray)) {
// batch remove
var i, done = keyOrArray.length;
var removeOne = function(i) {
self.remove(keyOrArray[i], function() {
if ((--done) > 0) { return; }
if (callback) {
self.lambda(callback).call(self);
}
});
};
for (i=0; i < keyOrArray.length; i++)
removeOne(i);
return this;
}
var key = this.name + '.' +
((keyOrArray.key) ? keyOrArray.key : keyOrArray)
this.indexer.del(key)
storage.removeItem(key)
if (callback) this.lambda(callback).call(this)
})
return this
}
}})());
return this
},
nuke: function (callback) {
this.all(function(r) {
for (var i = 0, l = r.length; i < l; i++) {
this.remove(r[i]);
}
if (callback) this.lambda(callback).call(this)
})
return this
}
}})());
}
Lawnchair.adapter('webkit-sqlite', (function() {

@@ -511,0 +521,0 @@ // private methods

@@ -7,3 +7,3 @@ /**

*/
var Lawnchair = function (options, callback) {
var Lawnchair = module.exports = function (options, callback) {
// ensure Lawnchair was called as a constructor

@@ -89,3 +89,3 @@ if (!(this instanceof Lawnchair)) return new Lawnchair(options, callback);

// methods required to implement a lawnchair adapter
var implementing = 'adapter valid init keys save batch get exists all remove nuke'.split(' ')
var implementing = 'adapter valid init keys close save batch get exists all remove nuke'.split(' ')
, indexOf = this.prototype.indexOf

@@ -167,2 +167,10 @@ // mix in the adapter

// --
};
};
require('./lawnchairHtml5FileSystem')(Lawnchair)
require('./lawnchairIndexDbAdapter')(Lawnchair)
require('./lawnchairLocalStorageAdapter')(Lawnchair)
require('./lawnchairMemoryAdapter')(Lawnchair)
require('./lawnchairTitanium')(Lawnchair)
require('./lawnchairWebkitSqlAdapter')(Lawnchair)
require('./lawnchairWindowNameStorageAdapter')(Lawnchair)

@@ -1,210 +0,212 @@

/**
* dom storage adapter
* ===
* - originally authored by Joseph Pecoraro
*
*/
//
// TODO does it make sense to be chainable all over the place?
// chainable: nuke, remove, all, get, save, all
// not chainable: valid, keys
//
Lawnchair.adapter('dom', (function() {
var storage = null;
try{
storage = window.localStorage;
}catch(e){
module.exports = function (Lawnchair) {
/**
* dom storage adapter
* ===
* - originally authored by Joseph Pecoraro
*
*/
//
// TODO does it make sense to be chainable all over the place?
// chainable: nuke, remove, all, get, save, all
// not chainable: valid, keys
//
Lawnchair.adapter('dom', (function() {
var storage = null;
try{
storage = window.localStorage;
}catch(e){
}
// the indexer is an encapsulation of the helpers needed to keep an ordered index of the keys
var indexer = function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
// the indexer is an encapsulation of the helpers needed to keep an ordered index of the keys
var indexer = function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
return JSON.parse(storage.getItem(this.key))
},
// adds a key to the index
add: function (key) {
var a = this.all()
a.push(key)
storage.setItem(this.key, JSON.stringify(a))
},
// deletes a key from the index
del: function (key) {
var a = this.all(), r = []
// FIXME this is crazy inefficient but I'm in a strata meeting and half concentrating
for (var i = 0, l = a.length; i < l; i++) {
if (a[i] != key) r.push(a[i])
}
storage.setItem(this.key, JSON.stringify(r))
},
// returns index for a key
find: function (key) {
var a = this.all()
for (var i = 0, l = a.length; i < l; i++) {
if (key === a[i]) return i
}
return false
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
return JSON.parse(storage.getItem(this.key))
},
// adds a key to the index
add: function (key) {
var a = this.all()
a.push(key)
storage.setItem(this.key, JSON.stringify(a))
},
// deletes a key from the index
del: function (key) {
var a = this.all(), r = []
// FIXME this is crazy inefficient but I'm in a strata meeting and half concentrating
for (var i = 0, l = a.length; i < l; i++) {
if (a[i] != key) r.push(a[i])
}
storage.setItem(this.key, JSON.stringify(r))
},
// returns index for a key
find: function (key) {
var a = this.all()
for (var i = 0, l = a.length; i < l; i++) {
if (key === a[i]) return i
}
return false
}
}
}
// adapter api
return {
// adapter api
return {
// ensure we are in an env with localStorage
valid: function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.setItem(value, value)
} catch (e) {
success = false
}
storage.removeItem(value)
return success
}()
},
// ensure we are in an env with localStorage
valid: function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.setItem(value, value)
} catch (e) {
success = false
}
storage.removeItem(value)
return success
}()
},
init: function (options, callback) {
this.indexer = indexer(this.name)
if (callback) this.fn(this.name, callback).call(this, this)
},
init: function (options, callback) {
this.indexer = indexer(this.name)
if (callback) this.fn(this.name, callback).call(this, this)
},
save: function (obj, callback) {
var key = obj.key ? this.name + '.' + obj.key : this.name + '.' + this.uuid()
// now we kil the key and use it in the store colleciton
delete obj.key;
storage.setItem(key, JSON.stringify(obj))
// if the key is not in the index push it on
if (this.indexer.find(key) === false) this.indexer.add(key)
obj.key = key.slice(this.name.length + 1)
if (callback) {
this.lambda(callback).call(this, obj)
}
return this
},
save: function (obj, callback) {
var key = obj.key ? this.name + '.' + obj.key : this.name + '.' + this.uuid()
// now we kil the key and use it in the store colleciton
delete obj.key;
storage.setItem(key, JSON.stringify(obj))
// if the key is not in the index push it on
if (this.indexer.find(key) === false) this.indexer.add(key)
obj.key = key.slice(this.name.length + 1)
if (callback) {
this.lambda(callback).call(this, obj)
}
return this
},
batch: function (ary, callback) {
var saved = []
// not particularily efficient but this is more for sqlite situations
for (var i = 0, l = ary.length; i < l; i++) {
this.save(ary[i], function(r){
saved.push(r)
})
}
if (callback) this.lambda(callback).call(this, saved)
return this
},
batch: function (ary, callback) {
var saved = []
// not particularily efficient but this is more for sqlite situations
for (var i = 0, l = ary.length; i < l; i++) {
this.save(ary[i], function(r){
saved.push(r)
})
}
if (callback) this.lambda(callback).call(this, saved)
return this
},
// accepts [options], callback
keys: function(callback) {
if (callback) {
var name = this.name
var indices = this.indexer.all();
var keys = [];
//Checking for the support of map.
if(Array.prototype.map) {
keys = indices.map(function(r){ return r.replace(name + '.', '') })
} else {
for (var key in indices) {
keys.push(key.replace(name + '.', ''));
// accepts [options], callback
keys: function(callback) {
if (callback) {
var name = this.name
var indices = this.indexer.all();
var keys = [];
//Checking for the support of map.
if(Array.prototype.map) {
keys = indices.map(function(r){ return r.replace(name + '.', '') })
} else {
for (var key in indices) {
keys.push(key.replace(name + '.', ''));
}
}
this.fn('keys', callback).call(this, keys)
}
this.fn('keys', callback).call(this, keys)
}
return this // TODO options for limit/offset, return promise
},
return this // TODO options for limit/offset, return promise
},
get: function (key, callback) {
if (this.isArray(key)) {
var r = []
for (var i = 0, l = key.length; i < l; i++) {
var k = this.name + '.' + key[i]
var obj = storage.getItem(k)
get: function (key, callback) {
if (this.isArray(key)) {
var r = []
for (var i = 0, l = key.length; i < l; i++) {
var k = this.name + '.' + key[i]
var obj = storage.getItem(k)
if (obj) {
obj = JSON.parse(obj)
obj.key = key[i]
}
r.push(obj)
}
if (callback) this.lambda(callback).call(this, r)
} else {
var k = this.name + '.' + key
var obj = storage.getItem(k)
if (obj) {
obj = JSON.parse(obj)
obj.key = key[i]
obj.key = key
}
r.push(obj)
if (callback) this.lambda(callback).call(this, obj)
}
if (callback) this.lambda(callback).call(this, r)
} else {
var k = this.name + '.' + key
var obj = storage.getItem(k)
if (obj) {
obj = JSON.parse(obj)
obj.key = key
}
if (callback) this.lambda(callback).call(this, obj)
}
return this
},
return this
},
exists: function (key, cb) {
var exists = this.indexer.find(this.name+'.'+key) === false ? false : true ;
this.lambda(cb).call(this, exists);
return this;
},
// NOTE adapters cannot set this.__results but plugins do
// this probably should be reviewed
all: function (callback) {
var idx = this.indexer.all()
, r = []
, o
, k
for (var i = 0, l = idx.length; i < l; i++) {
k = idx[i] //v
o = JSON.parse(storage.getItem(k))
o.key = k.replace(this.name + '.', '')
r.push(o)
}
if (callback) this.fn(this.name, callback).call(this, r)
return this
},
remove: function (keyOrArray, callback) {
var self = this;
if (this.isArray(keyOrArray)) {
// batch remove
var i, done = keyOrArray.length;
var removeOne = function(i) {
self.remove(keyOrArray[i], function() {
if ((--done) > 0) { return; }
if (callback) {
self.lambda(callback).call(self);
}
});
};
for (i=0; i < keyOrArray.length; i++)
removeOne(i);
exists: function (key, cb) {
var exists = this.indexer.find(this.name+'.'+key) === false ? false : true ;
this.lambda(cb).call(this, exists);
return this;
}
var key = this.name + '.' +
((keyOrArray.key) ? keyOrArray.key : keyOrArray)
this.indexer.del(key)
storage.removeItem(key)
if (callback) this.lambda(callback).call(this)
return this
},
},
// NOTE adapters cannot set this.__results but plugins do
// this probably should be reviewed
all: function (callback) {
var idx = this.indexer.all()
, r = []
, o
, k
for (var i = 0, l = idx.length; i < l; i++) {
k = idx[i] //v
o = JSON.parse(storage.getItem(k))
o.key = k.replace(this.name + '.', '')
r.push(o)
}
if (callback) this.fn(this.name, callback).call(this, r)
return this
},
nuke: function (callback) {
this.all(function(r) {
for (var i = 0, l = r.length; i < l; i++) {
this.remove(r[i]);
remove: function (keyOrArray, callback) {
var self = this;
if (this.isArray(keyOrArray)) {
// batch remove
var i, done = keyOrArray.length;
var removeOne = function(i) {
self.remove(keyOrArray[i], function() {
if ((--done) > 0) { return; }
if (callback) {
self.lambda(callback).call(self);
}
});
};
for (i=0; i < keyOrArray.length; i++)
removeOne(i);
return this;
}
var key = this.name + '.' +
((keyOrArray.key) ? keyOrArray.key : keyOrArray)
this.indexer.del(key)
storage.removeItem(key)
if (callback) this.lambda(callback).call(this)
})
return this
}
}})());
return this
},
nuke: function (callback) {
this.all(function(r) {
for (var i = 0, l = r.length; i < l; i++) {
this.remove(r[i]);
}
if (callback) this.lambda(callback).call(this)
})
return this
}
}})());
}

@@ -1,2 +0,2 @@

Copyright (C) 2012-2018 by various contributors (see AUTHORS)
Copyright (C) 2012-2014 by various contributors (see AUTHORS)

@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -1,2 +0,2 @@

Copyright (c) 2012-2014 Raynos.
Copyright (c) 2012 Raynos.

@@ -19,2 +19,2 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.WARE.
{
"name": "fh-js-sdk",
"version": "3.1.0-dev",
"version": "4.0.0-beta",
"description": "feedhenry js sdk",

@@ -5,0 +5,0 @@ "main": "dist/feedhenry.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc