shared-store
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -0,1 +1,8 @@ | ||
1.0.5 | ||
----- | ||
* fix first error to store.init callback - @chkhoo #9 | ||
* Put more focus on loader `options` in example - @jkrems #7 | ||
* remove redundant npub tasks & Observable declarations - @chkhoo #6 | ||
* fix err typo in README.md - @chkhoo #3 | ||
1.0.4 | ||
@@ -2,0 +9,0 @@ ----- |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -35,3 +35,3 @@ /* | ||
'use strict'; | ||
var Observable, activeLoader, cleanup, crashRecovery, debug, dirContent, fromPromiseFunction, fs, identity, isCacheFile, isEqual, latestCacheFile, latestFile, mkdirp, mkdirpStream, partial, passiveLoader, path, promisify, property, readCacheFile, readFile, ref, sortByMostRecent, timestampName, tryCache, unlink, writeCache, writeFile; | ||
var Observable, activeLoader, cleanup, crashRecovery, debug, dirContent, fromPromiseFunction, fs, identity, isCacheFile, isEqual, latestCacheFile, latestFile, mkdirp, mkdirpStream, partial, passiveLoader, path, promisify, property, readCacheFile, readFile, sortByMostRecent, timestampName, tryCache, unlink, writeCache, writeFile, _ref; | ||
@@ -48,3 +48,3 @@ path = require('path'); | ||
ref = require('lodash'), identity = ref.identity, isEqual = ref.isEqual, property = ref.property, partial = ref.partial; | ||
_ref = require('lodash'), identity = _ref.identity, isEqual = _ref.isEqual, property = _ref.property, partial = _ref.partial; | ||
@@ -69,5 +69,5 @@ debug = require('debug')('shared-store:cache'); | ||
isCacheFile = function(arg) { | ||
isCacheFile = function(_arg) { | ||
var filename; | ||
filename = arg.filename; | ||
filename = _arg.filename; | ||
return /[\d-]+T[\d]+Z\.json/.test(filename); | ||
@@ -95,8 +95,8 @@ }; | ||
readCacheFile = function(arg) { | ||
readCacheFile = function(_arg) { | ||
var absolute; | ||
absolute = arg.absolute; | ||
return readFile(absolute).then(JSON.parse).then(function(arg1) { | ||
absolute = _arg.absolute; | ||
return readFile(absolute).then(JSON.parse).then(function(_arg1) { | ||
var data, time; | ||
data = arg1.data, time = arg1.time; | ||
data = _arg1.data, time = _arg1.time; | ||
return { | ||
@@ -103,0 +103,0 @@ data: data, |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -3,0 +3,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -35,3 +35,3 @@ /* | ||
'use strict'; | ||
var Observable, Promise, compose, debug, dirChanges, dirContent, extend, fromPromiseFunction, fs, niceStat, path, promisify, readdir, ref, stat; | ||
var Observable, Promise, compose, debug, dirChanges, dirContent, extend, fromPromiseFunction, fs, niceStat, path, promisify, readdir, stat, _ref; | ||
@@ -46,3 +46,3 @@ path = require('path'); | ||
ref = require('lodash'), extend = ref.extend, compose = ref.compose; | ||
_ref = require('lodash'), extend = _ref.extend, compose = _ref.compose; | ||
@@ -63,5 +63,5 @@ debug = require('debug')('shared-store:dir-content'); | ||
dirChanges = function(dir, arg) { | ||
dirChanges = function(dir, _arg) { | ||
var statFiles; | ||
statFiles = (arg != null ? arg : {}).statFiles; | ||
statFiles = (_arg != null ? _arg : {}).statFiles; | ||
if (statFiles == null) { | ||
@@ -93,4 +93,4 @@ statFiles = false; | ||
return niceStat(props, absolute).done(onNext, function(error) { | ||
var code, ref1; | ||
code = (ref1 = error.cause) != null ? ref1.code : void 0; | ||
var code, _ref1; | ||
code = (_ref1 = error.cause) != null ? _ref1.code : void 0; | ||
debug('stat failed: %s', code, filename); | ||
@@ -113,5 +113,5 @@ if (code === 'ENOENT') { | ||
dirContent = function(dir, arg) { | ||
var initial, ref1, statDir, statFiles, watch; | ||
ref1 = arg != null ? arg : {}, watch = ref1.watch, statFiles = ref1.statFiles; | ||
dirContent = function(dir, _arg) { | ||
var initial, statDir, statFiles, watch, _ref1; | ||
_ref1 = _arg != null ? _arg : {}, watch = _ref1.watch, statFiles = _ref1.statFiles; | ||
if (statFiles == null) { | ||
@@ -118,0 +118,0 @@ statFiles = false; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -35,3 +35,3 @@ /* | ||
'use strict'; | ||
var CSON, Observable, Promise, debug, dirChanges, fileChanges, fileContent, fromPromiseFunction, fs, identity, isMissingError, onInterval, parserFromExtension, partial, path, promisify, readFile, ref; | ||
var CSON, Promise, debug, dirChanges, fileChanges, fileContent, fromPromiseFunction, fs, identity, isMissingError, onInterval, parserFromExtension, partial, path, promisify, readFile, _ref; | ||
@@ -42,7 +42,5 @@ fs = require('fs'); | ||
Observable = require('rx').Observable; | ||
promisify = (Promise = require('bluebird')).promisify; | ||
ref = require('lodash'), partial = ref.partial, identity = ref.identity; | ||
_ref = require('lodash'), partial = _ref.partial, identity = _ref.identity; | ||
@@ -62,5 +60,5 @@ CSON = require('cson-parser'); | ||
fileChanges = function(filename, options) { | ||
return dirChanges(path.dirname(filename), options).filter(function(arg) { | ||
return dirChanges(path.dirname(filename), options).filter(function(_arg) { | ||
var absolute; | ||
absolute = arg.absolute; | ||
absolute = _arg.absolute; | ||
return absolute === filename; | ||
@@ -67,0 +65,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -35,3 +35,3 @@ /* | ||
'use strict'; | ||
var Observable, Promise, debug, fromPromiseFunction, httpResource, onInterval, partial; | ||
var Promise, debug, fromPromiseFunction, httpResource, onInterval, partial; | ||
@@ -42,4 +42,2 @@ Promise = require('bluebird'); | ||
Observable = require('rx').Observable; | ||
partial = require('lodash').partial; | ||
@@ -51,5 +49,5 @@ | ||
httpResource = function(arg) { | ||
httpResource = function(_arg) { | ||
var checkModified, fetch, interval, lastBody, lastETag, lastModified, load, returnLastKnown, wrap; | ||
fetch = arg.fetch, interval = arg.interval; | ||
fetch = _arg.fetch, interval = _arg.interval; | ||
lastETag = void 0; | ||
@@ -68,5 +66,5 @@ lastModified = void 0; | ||
}; | ||
checkModified = function(arg1) { | ||
checkModified = function(_arg1) { | ||
var body, headers, response, statusCode, url; | ||
response = arg1.response, body = arg1.body, url = arg1.url; | ||
response = _arg1.response, body = _arg1.body, url = _arg1.url; | ||
headers = response.headers, statusCode = response.statusCode; | ||
@@ -73,0 +71,0 @@ if (statusCode === 304) { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -3,0 +3,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -68,5 +68,5 @@ /* | ||
getMTime = function(arg) { | ||
getMTime = function(_arg) { | ||
var mtime; | ||
mtime = arg.mtime; | ||
mtime = _arg.mtime; | ||
return mtime.getTime(); | ||
@@ -73,0 +73,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -35,5 +35,5 @@ /* | ||
'use strict'; | ||
var Observable, Promise, config, fromPromiseFunction, ref; | ||
var Observable, Promise, config, fromPromiseFunction, _ref; | ||
ref = require('rx'), Observable = ref.Observable, config = ref.config; | ||
_ref = require('rx'), Observable = _ref.Observable, config = _ref.config; | ||
@@ -40,0 +40,0 @@ Promise = require('bluebird'); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -35,6 +35,6 @@ /* | ||
'use strict'; | ||
var filter, max, merge, pluck, reduce, ref, safeMerge, sourceList, toArray, | ||
slice = [].slice; | ||
var filter, max, merge, pluck, reduce, safeMerge, sourceList, toArray, _ref, | ||
__slice = [].slice; | ||
ref = require('lodash'), merge = ref.merge, pluck = ref.pluck, max = ref.max, reduce = ref.reduce, filter = ref.filter; | ||
_ref = require('lodash'), merge = _ref.merge, pluck = _ref.pluck, max = _ref.max, reduce = _ref.reduce, filter = _ref.filter; | ||
@@ -58,4 +58,4 @@ toArray = function(value) { | ||
var args, data, source, time; | ||
args = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
data = merge.apply(null, [{}].concat(slice.call(pluck(args, 'data')))); | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
data = merge.apply(null, [{}].concat(__slice.call(pluck(args, 'data')))); | ||
time = max(filter(pluck(args, 'time'))); | ||
@@ -62,0 +62,0 @@ source = reduce(pluck(args, 'source'), sourceList); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.0 | ||
@@ -36,5 +36,5 @@ /* | ||
var EventEmitter, Observable, Promise, SharedStore, cachedLoader, cluster, freeze, path, property, safeMerge, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
__hasProp = {}.hasOwnProperty; | ||
@@ -59,9 +59,10 @@ path = require('path'); | ||
SharedStore = (function(superClass) { | ||
extend(SharedStore, superClass); | ||
SharedStore = (function(_super) { | ||
__extends(SharedStore, _super); | ||
function SharedStore(arg) { | ||
function SharedStore(_arg) { | ||
var active, loader, meta, temp; | ||
loader = arg.loader, temp = arg.temp, active = arg.active; | ||
this._handleUpdate = bind(this._handleUpdate, this); | ||
loader = _arg.loader, temp = _arg.temp, active = _arg.active; | ||
this._handleUpdate = __bind(this._handleUpdate, this); | ||
this._handleError = __bind(this._handleError, this); | ||
EventEmitter.call(this); | ||
@@ -80,3 +81,4 @@ if (active == null) { | ||
this.stream = cachedLoader(meta, loader, temp, active, this.emit.bind(this, 'error')); | ||
this._subscription = this.stream.subscribe(this._handleUpdate); | ||
this._receivedData = false; | ||
this._subscription = this.stream.subscribe(this._handleUpdate, this._handleError); | ||
this._cache = null; | ||
@@ -86,4 +88,4 @@ } | ||
SharedStore.prototype.getCurrent = function() { | ||
var ref; | ||
return (ref = this._cache) != null ? ref.data : void 0; | ||
var _ref; | ||
return (_ref = this._cache) != null ? _ref.data : void 0; | ||
}; | ||
@@ -103,4 +105,3 @@ | ||
return function(resolve, reject) { | ||
_this.once('error', reject); | ||
return _this.stream.take(1).map(property('data')).subscribe(resolve); | ||
return _this.stream.take(1).map(property('data')).subscribe(resolve, reject); | ||
}; | ||
@@ -112,5 +113,13 @@ })(this)); | ||
SharedStore.prototype._handleUpdate = function(arg) { | ||
var data, ref, source, time; | ||
data = arg.data, time = arg.time, source = arg.source; | ||
SharedStore.prototype._handleError = function(err) { | ||
if (!this._receivedData) { | ||
return; | ||
} | ||
return this.emit('error', err); | ||
}; | ||
SharedStore.prototype._handleUpdate = function(_arg) { | ||
var data, source, time, _ref; | ||
data = _arg.data, time = _arg.time, source = _arg.source; | ||
this._receivedData = true; | ||
this._cache = freeze({ | ||
@@ -123,3 +132,3 @@ data: data, | ||
isWorker: cluster.isWorker, | ||
id: (ref = cluster.worker) != null ? ref.id : void 0 | ||
id: (_ref = cluster.worker) != null ? _ref.id : void 0 | ||
}); | ||
@@ -126,0 +135,0 @@ return this.emit('data', this._cache.data); |
{ | ||
"name": "shared-store", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Keeping config data in sync", | ||
@@ -27,15 +27,11 @@ "main": "lib/shared-store.js", | ||
"test": "mocha", | ||
"posttest": "npub verify", | ||
"setup": "rm -rf node_modules && npm install --registry ${npm_package_publishConfig_registry}", | ||
"release-patch": "npm run setup && npub publish patch", | ||
"release-minor": "npm run setup && npub publish minor", | ||
"release-major": "npm run setup && npub publish major" | ||
"posttest": "npub verify" | ||
}, | ||
"devDependencies": { | ||
"assertive": "^1.4.1", | ||
"coffee-script": "^1.8.0", | ||
"coffeelint": "^1.8.1", | ||
"coffee-script": "1.9.0", | ||
"coffeelint": "^1.9.2", | ||
"mocha": "^2.1.0", | ||
"nodemon": "^1.3.7", | ||
"npub": "^1.0.0", | ||
"npub": "^2.0.1", | ||
"rimraf": "^2.2.8", | ||
@@ -42,0 +38,0 @@ "tmp": "0.0.24" |
@@ -37,4 +37,4 @@ # shared-store | ||
loader() { | ||
return fileContent('conf/application.json', { | ||
loader(options) { | ||
return fileContent(options.filename, { | ||
watch: true | ||
@@ -46,4 +46,4 @@ }); | ||
// Load the initial configuration | ||
store.init((error, config) => { | ||
if (error) throw err; | ||
store.init({ filename: 'conf/application.json' }, (error, config) => { | ||
if (error) throw error; | ||
@@ -50,0 +50,0 @@ // The `config` variable was passed into the callback for convenience |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
91374
41
1060
1