compact-encoding
Advanced tools
Comparing version 2.15.1 to 2.16.0
16
index.js
@@ -495,2 +495,14 @@ const b4a = require('b4a') | ||
exports.date = { | ||
preencode (state, d) { | ||
uint.preencode(state, d.getTime()) | ||
}, | ||
encode (state, d) { | ||
uint.encode(state, d.getTime()) | ||
}, | ||
decode (state, d) { | ||
return new Date(uint.decode(state)) | ||
} | ||
} | ||
exports.json = { | ||
@@ -595,3 +607,4 @@ preencode (state, v) { | ||
anyArray, | ||
anyObject | ||
anyObject, | ||
exports.date | ||
] | ||
@@ -627,2 +640,3 @@ | ||
if (Array.isArray(o)) return 7 | ||
if (o instanceof Date) return 9 | ||
if (typeof o === 'object') return 8 | ||
@@ -629,0 +643,0 @@ |
{ | ||
"name": "compact-encoding", | ||
"version": "2.15.1", | ||
"version": "2.16.0", | ||
"description": "A series of compact encoding schemes for building small and fast parsers and serializers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -146,2 +146,3 @@ # compact-encoding | ||
* `cenc.fixed(n)` - Makes a fixed sized encoder. | ||
* `cenc.date(d)` - Encodes a date object. | ||
* `cenc.array(enc)` - Makes an array encoder from another encoder. Arrays are uint prefixed with their length. | ||
@@ -148,0 +149,0 @@ * `cenc.raw.array(enc)` - Makes an array encoder from another encoder, without a length prefixed. |
@@ -813,2 +813,8 @@ const enc = require('./') | ||
test('date', function (t) { | ||
const d = new Date() | ||
t.alike(enc.decode(enc.date, enc.encode(enc.date, d)), d) | ||
}) | ||
test('any', function (t) { | ||
@@ -821,2 +827,3 @@ const o = { | ||
nest: {}, | ||
today: new Date(), | ||
float: 0.54 | ||
@@ -823,0 +830,0 @@ } |
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
71731
1581
160