Comparing version 0.0.1 to 0.1.0
/* globals atob, btoa */ | ||
/* istanbul ignore file */ | ||
'use strict' | ||
@@ -3,0 +4,0 @@ const bytes = require('./core') |
@@ -28,3 +28,7 @@ 'use strict' | ||
bytes.compare = (a, b) => !bytes.sort(a, b) | ||
bytes.memcopy = (_from, encoding) => { | ||
const b = bytes(_from, encoding) | ||
return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) | ||
} | ||
module.exports = bytes |
{ | ||
"name": "bytesish", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"main": "node.js", | ||
"browser": "browser.js", | ||
"scripts": { | ||
"test": "aegir test -t node browser", | ||
"test": "nyc --check-coverage --branches 100 --functions 100 --lines 100 aegir test -t node browser", | ||
"pretest": "aegir lint" | ||
@@ -9,0 +9,0 @@ }, |
@@ -25,4 +25,41 @@ 'use strict' | ||
assert(!bytes.compare(a, b)) | ||
assert(!bytes.compare(b, a)) | ||
assert(!bytes.compare(a, '123')) | ||
assert(!bytes.compare('123', a)) | ||
done() | ||
}) | ||
test('double view', done => { | ||
const a = bytes('hello world') | ||
const b = bytes(a) | ||
same(a, b) | ||
done() | ||
}) | ||
test('array buffer', done => { | ||
const a = bytes('hello world') | ||
const b = bytes(bytes.memcopy(a)) | ||
same(bytes.toString(a), bytes.toString(b)) | ||
done() | ||
}) | ||
test('Uint8Array', done => { | ||
const a = bytes('hello world') | ||
const b = bytes(new Uint8Array(bytes.memcopy(a))) | ||
same(bytes.toString(a), bytes.toString(b)) | ||
done() | ||
}) | ||
test('native', done => { | ||
let n = bytes.native('hello world') | ||
if (process.browser) { | ||
assert(n instanceof Uint8Array) | ||
n = bytes.native(n) | ||
assert(n instanceof Uint8Array) | ||
} else { | ||
assert(n instanceof Buffer) | ||
n = bytes.native(n) | ||
assert(n instanceof Buffer) | ||
} | ||
done() | ||
}) |
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
8674
151