Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bytesish

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytesish - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

1

browser.js
/* 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

4

package.json
{
"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()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc