Skip to content

Commit

Permalink
Update all outdated deps and remove 0.10 and 0.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mhart committed Jun 19, 2018
1 parent 24703a7 commit 2e54ec0
Show file tree
Hide file tree
Showing 11 changed files with 1,625 additions and 38 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ node_modules
npm-debug.log
coverage*
.tern-port
package-lock.json
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "4.2"
- "4"
- "6"
- "8"
- "10"
2 changes: 1 addition & 1 deletion actions/createStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function createStream(store, data, cb) {
'for current limits and how to request higher limits.'))
}

var i, shards = new Array(data.ShardCount), shardHash = POW_128.div(data.ShardCount).floor(),
var i, shards = new Array(data.ShardCount), shardHash = POW_128.div(data.ShardCount).integerValue(BigNumber.ROUND_FLOOR),
createTime = Date.now() - SEQ_ADJUST_MS, stream
for (i = 0; i < data.ShardCount; i++) {
shards[i] = {
Expand Down
6 changes: 3 additions & 3 deletions actions/putRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function putRecord(store, data, cb) {
if (data.ExplicitHashKey != null) {
hashKey = new BigNumber(data.ExplicitHashKey)

if (hashKey.cmp(0) < 0 || hashKey.cmp(new BigNumber(2).pow(128)) >= 0) {
if (hashKey.comparedTo(0) < 0 || hashKey.comparedTo(new BigNumber(2).pow(128)) >= 0) {
return cb(db.clientError('InvalidArgumentException',
'Invalid ExplicitHashKey. ExplicitHashKey must be in the range: [0, 2^128-1]. ' +
'Specified value was ' + data.ExplicitHashKey))
Expand All @@ -43,8 +43,8 @@ module.exports = function putRecord(store, data, cb) {

for (var i = 0; i < stream.Shards.length; i++) {
if (stream.Shards[i].SequenceNumberRange.EndingSequenceNumber == null &&
hashKey.cmp(stream.Shards[i].HashKeyRange.StartingHashKey) >= 0 &&
hashKey.cmp(stream.Shards[i].HashKeyRange.EndingHashKey) <= 0) {
hashKey.comparedTo(stream.Shards[i].HashKeyRange.StartingHashKey) >= 0 &&
hashKey.comparedTo(stream.Shards[i].HashKeyRange.EndingHashKey) <= 0) {
shardIx = i
shardId = stream.Shards[i].ShardId
shardCreateTime = db.parseSequence(
Expand Down
6 changes: 3 additions & 3 deletions actions/putRecords.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function putRecords(store, data, cb) {
if (record.ExplicitHashKey != null) {
hashKey = new BigNumber(record.ExplicitHashKey)

if (hashKey.cmp(0) < 0 || hashKey.cmp(new BigNumber(2).pow(128)) >= 0) {
if (hashKey.comparedTo(0) < 0 || hashKey.comparedTo(new BigNumber(2).pow(128)) >= 0) {
return cb(db.clientError('InvalidArgumentException',
'Invalid ExplicitHashKey. ExplicitHashKey must be in the range: [0, 2^128-1]. ' +
'Specified value was ' + record.ExplicitHashKey))
Expand All @@ -36,8 +36,8 @@ module.exports = function putRecords(store, data, cb) {

for (var j = 0; j < stream.Shards.length; j++) {
if (stream.Shards[j].SequenceNumberRange.EndingSequenceNumber == null &&
hashKey.cmp(stream.Shards[j].HashKeyRange.StartingHashKey) >= 0 &&
hashKey.cmp(stream.Shards[j].HashKeyRange.EndingHashKey) <= 0) {
hashKey.comparedTo(stream.Shards[j].HashKeyRange.StartingHashKey) >= 0 &&
hashKey.comparedTo(stream.Shards[j].HashKeyRange.EndingHashKey) <= 0) {
seqPieces[i] = {
shardIx: j,
shardId: stream.Shards[j].ShardId,
Expand Down
8 changes: 4 additions & 4 deletions db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var crypto = require('crypto'),
levelup = require('levelup'),
memdown = require('memdown'),
sublevel = require('level-sublevel'),
Lock = require('lock'),
lock = require('lock'),
BigNumber = require('bignumber.js')

exports.create = create
Expand All @@ -28,12 +28,12 @@ function create(options) {
if (options.updateStreamMs == null) options.updateStreamMs = 500
if (options.shardLimit == null) options.shardLimit = 10

var db = levelup(options.path || '/does/not/matter', options.path ? {} : {db: memdown}),
var db = levelup(options.path ? require('leveldown')(options.path) : memdown()),
sublevelDb = sublevel(db),
metaDb = sublevelDb.sublevel('meta', {valueEncoding: 'json'}),
streamDbs = []

metaDb.lock = new Lock()
metaDb.lock = lock.Lock()

// XXX: Is there a better way to get this?
metaDb.awsAccountId = (process.env.AWS_ACCOUNT_ID || '0000-0000-0000').replace(/[^\d]/g, '')
Expand All @@ -42,7 +42,7 @@ function create(options) {
function getStreamDb(name) {
if (!streamDbs[name]) {
streamDbs[name] = sublevelDb.sublevel('stream-' + name, {valueEncoding: 'json'})
streamDbs[name].lock = new Lock()
streamDbs[name].lock = lock.Lock()
}
return streamDbs[name]
}
Expand Down
Loading

0 comments on commit 2e54ec0

Please sign in to comment.