Comparing version 1.5.3 to 1.5.4
@@ -160,2 +160,4 @@ var varint = require('varint') | ||
var type = getType(value) | ||
if ('function' !== typeof encodingLengthers[type]) | ||
throw new Error('unknown type:' + type + ', ' + JSON.stringify(value)) | ||
var len = encodingLengthers[type](value) | ||
@@ -162,0 +164,0 @@ return varint.encodingLength(len << TAG_SIZE) + len |
{ | ||
"name": "bipf", | ||
"description": "binary in-place format", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"homepage": "https://github.com/ssbc/bipf", | ||
@@ -6,0 +6,0 @@ "repository": { |
const tape = require('tape') | ||
const bipf = require('../') | ||
const pkg = require('../package.json') | ||
const pkg = { | ||
name: 'test', | ||
version: '1.0.0', | ||
description: 'test package', | ||
repository: { | ||
type: 'git', | ||
url: 'git://github.com/ssbc/bipf.git', | ||
}, | ||
dependencies: { | ||
varint: '^5.0.0', | ||
}, | ||
husky: { | ||
hooks: { | ||
'pre-commit': 'npm run format-code-staged', | ||
}, | ||
}, | ||
} | ||
/* | ||
@@ -49,2 +66,5 @@ json types: | ||
testEncodeDecode(-1) | ||
testEncodeDecode(-100) | ||
testEncodeDecode(123.456) | ||
testEncodeDecode(-123.456) | ||
testEncodeDecode(true) | ||
@@ -60,2 +80,25 @@ testEncodeDecode(false) | ||
testEncodeDecode('hello') | ||
testEncodeDecode( | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' + | ||
'123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_' | ||
) | ||
testEncodeDecode({ foo: true }) | ||
@@ -104,2 +147,7 @@ testEncodeDecode([-1, { foo: true }, Buffer.from('deadbeef', 'hex')]) | ||
tape('error: encode(NaN)', (t) => { | ||
t.throws(() => bipf.encode(NaN), /unknown type/) | ||
t.end() | ||
}) | ||
tape('seekKey() on an object', (t) => { | ||
@@ -106,0 +154,0 @@ const objEncoded = bipf.allocAndEncode({ x: 10, y: 20 }) |
47994
1168