block-sequence
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -5,3 +5,8 @@ var EventEmitter = require('events').EventEmitter | ||
var async = require('async') | ||
var _ = require('lodash') | ||
var get = require('lodash.get') | ||
var has = require('lodash.has') | ||
var once = require('lodash.once') | ||
var padStart = require('lodash.padstart') | ||
var defaultsDeep = require('lodash.defaultsdeep') | ||
var dot = require('dot') | ||
@@ -11,9 +16,9 @@ | ||
var driver = _.get(config, 'driver') | ||
var prime = _.has(config, 'prime') ? config.prime : true | ||
var size = _.get(config, 'size') || 1000 | ||
var retries = _.get(config, 'retry.limit') || 1000 | ||
var interval = _.get(config, 'retry.interval') || 100 | ||
var template = _.has(config, 'template') && dot.template(config.template) | ||
var padding = _.defaultsDeep(_.get(config, 'padding') || {}, { size: 0, chars: '0' }) | ||
var driver = get(config, 'driver') | ||
var prime = has(config, 'prime') ? config.prime : true | ||
var size = get(config, 'size') || 1000 | ||
var retries = get(config, 'retry.limit') || 1000 | ||
var interval = get(config, 'retry.interval') || 100 | ||
var template = has(config, 'template') && dot.template(config.template) | ||
var padding = defaultsDeep(get(config, 'padding') || {}, { size: 0, chars: '0' }) | ||
var queue = async.queue(getId, 1) | ||
@@ -26,5 +31,5 @@ var sequence | ||
var initOnce = _.once(function init() { | ||
if (!_.has(config, 'driver')) return self.emit('error', new Error('driver is required')) | ||
if (!_.has(config, 'sequence.name')) return self.emit('error', new Error('sequence name is required')) | ||
var initOnce = once(function init() { | ||
if (!has(config, 'driver')) return self.emit('error', new Error('driver is required')) | ||
if (!has(config, 'sequence.name')) return self.emit('error', new Error('sequence name is required')) | ||
driver.ensure(config.sequence, function(err, _sequence) { | ||
@@ -63,3 +68,3 @@ if (err) return self.emit('error', err) | ||
var id = block.next | ||
if (padding.size) id = _.padStart(id, padding.size, padding.chars) | ||
if (padding.size) id = padStart(id, padding.size, padding.chars) | ||
if (template) id = template({ id: id, sequence: sequence }) | ||
@@ -66,0 +71,0 @@ block.next++ |
var debug = require('debug')('block-sequence:blockarray') | ||
var EventEmitter = require('events').EventEmitter | ||
var util = require('util') | ||
var _ = require('lodash') | ||
var times = require('lodash.times') | ||
var Block = require('./Block') | ||
@@ -11,3 +11,3 @@ | ||
var blockIndex = 0 | ||
var blockList = _.times(config.size || 2, function() { | ||
var blockList = times(config.size || 2, function() { | ||
return new Block(config.block) | ||
@@ -14,0 +14,0 @@ .on('drained', function() { |
{ | ||
"name": "block-sequence", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "A sequential id generator, which grabs blocks of ids rather than just one at a time", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha", | ||
"test": "mocha test", | ||
"lint": "eslint .", | ||
"istanbul": "istanbul cover --report html --report lcov _mocha", | ||
"codeclimate": "(test -e .codeclimate && npm run istanbul && source .codeclimate) || echo skipping codeclimate", | ||
"coverage": "nyc --report html --reporter lcov --reporter text-summary mocha test", | ||
"codeclimate": "(test -e .codeclimate && npm run coverage && source .codeclimate) || echo skipping codeclimate", | ||
"precommit": "npm run lint && npm test", | ||
@@ -23,15 +23,20 @@ "prepush": "npm run codeclimate" | ||
"dependencies": { | ||
"async": "^2.6.1", | ||
"debug": "^4.0.1", | ||
"async": "^2.6.2", | ||
"debug": "^4.1.1", | ||
"dot": "^1.1.2", | ||
"lodash": "^4.17.11" | ||
"lodash.defaultsdeep": "^4.6.0", | ||
"lodash.get": "^4.4.2", | ||
"lodash.has": "^4.5.2", | ||
"lodash.once": "^4.1.1", | ||
"lodash.padstart": "^4.6.1", | ||
"lodash.times": "^4.3.2" | ||
}, | ||
"devDependencies": { | ||
"block-sequence-reference": "^0.1.0", | ||
"eslint": "^5.6.1", | ||
"eslint": "^5.16.0", | ||
"eslint-config-imperative": "^2.1.0", | ||
"eslint-plugin-imperative": "^2.1.0", | ||
"husky": "^1.1.1", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.2.0" | ||
"husky": "^1.3.1", | ||
"mocha": "^6.1.0", | ||
"nyc": "^13.3.0" | ||
}, | ||
@@ -38,0 +43,0 @@ "directories": { |
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
24343
455
9
+ Addedlodash.defaultsdeep@^4.6.0
+ Addedlodash.get@^4.4.2
+ Addedlodash.has@^4.5.2
+ Addedlodash.once@^4.1.1
+ Addedlodash.padstart@^4.6.1
+ Addedlodash.times@^4.3.2
+ Addedlodash.defaultsdeep@4.6.1(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedlodash.has@4.5.2(transitive)
+ Addedlodash.once@4.1.1(transitive)
+ Addedlodash.padstart@4.6.1(transitive)
+ Addedlodash.times@4.3.2(transitive)
- Removedlodash@^4.17.11
Updatedasync@^2.6.2
Updateddebug@^4.1.1