Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove node globals #46

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .dockerignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .jsdoc.conf

This file was deleted.

6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

62 changes: 35 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
sudo: false
language: node_js
cache: npm
stages:
- check
- test
- cov

matrix:
include:
- node_js: 8
env: CXX=g++-4.8
- node_js: 10
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8
node_js:
- '10'
- '12'

os:
- linux
- osx
- windows

script:
- yarn lint
- yarn test
- yarn coverage
script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- stage: test
name: chrome
addons:
chrome: stable
script: npx aegir test -t browser -t webworker

after_success:
- yarn coverage-publish
- stage: test
name: firefox
addons:
firefox: latest
script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless

addons:
firefox: 'latest'
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
notifications:
email: false
21 changes: 0 additions & 21 deletions .waiting.html

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[![Coverage Status](https://coveralls.io/repos/github/dignifiedquire/borc/badge.svg?branch=master)](https://coveralls.io/github/dignifiedquire/borc?branch=master)
[![Dependency Status](https://david-dm.org/dignifiedquire/borc.svg?style=flat-square)](https://david-dm.org/dignifiedquire/borc)
[![Travis CI](https://travis-ci.org/dignifiedquire/borc.svg?branch=master)](https://travis-ci.org/dignifiedquire/borc)
[![Circle CI](https://circleci.com/gh/dignifiedquire/borc.svg?style=svg)](https://circleci.com/gh/dignifiedquire/borc)


> Assimilate all your JavaScript objects into the Concise Binary Object Representation (CBOR) data format ([RFC7049](http://tools.ietf.org/html/rfc7049)) **as fast as possible**.
Expand Down
11 changes: 7 additions & 4 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
'use strict'

console.log('PID: %s', process.pid)
Expand All @@ -24,7 +25,7 @@ const buffers = vectors

const suite = new Benchmark.Suite('cbor')

let vecLength = vectors.length
const vecLength = vectors.length
let res = []

suite.add(`encode - node-cbor - ${vecLength}`, () => {
Expand All @@ -40,9 +41,11 @@ suite.add(`encode - borc - ${vecLength}`, () => {
})

suite.add(`encode - stream - borc - ${vecLength}`, () => {
const enc = new fastCbor.Encoder({ stream (chunk) {
res.push(chunk)
} })
const enc = new fastCbor.Encoder({
stream (chunk) {
res.push(chunk)
}
})
for (let i = 0; i < vecLength; i++) {
enc.write(vectors[i].decoded)
}
Expand Down
2 changes: 1 addition & 1 deletion bin/cbor2comment
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
'use strict'

const cbor = require('../src/cbor')
const cbor = require('../src')
const utils = require('../src/utils')
const pkg = require('../package.json')

Expand Down
2 changes: 1 addition & 1 deletion bin/cbor2diag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
'use strict'

const cbor = require('../src/cbor')
const cbor = require('../src')
const utils = require('../src/utils')
const pkg = require('../package.json')

Expand Down
3 changes: 2 additions & 1 deletion bin/cbor2json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
/* eslint-disable no-console */
'use strict'

const cbor = require('../src/cbor')
const cbor = require('../src')
const utils = require('../src/utils')
const pkg = require('../package.json')

Expand Down
2 changes: 1 addition & 1 deletion bin/json2cbor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
'use strict'

const cbor = require('../src/cbor')
const cbor = require('../src')
const utils = require('../src/utils')
const pkg = require('../package.json')

Expand Down
12 changes: 0 additions & 12 deletions circle.yml

This file was deleted.

15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"browser": {
"fs": false
},
"files": [
"src",
"dist"
],
"scripts": {
"test": "aegir test --files test/**/*.spec.js",
"test:browser": "aegir test --target browser",
Expand Down Expand Up @@ -38,7 +42,8 @@
"email": "[email protected]"
},
"devDependencies": {
"aegir": "^18.0.1",
"aegir": "^21.4.5",
"ava": "^3.5.1",
"benchmark": "^2.1.0",
"budo": "^11.2.0",
"cbor": "^4.0.0",
Expand All @@ -50,10 +55,12 @@
"readmeFilename": "README.md",
"dependencies": {
"bignumber.js": "^9.0.0",
"buffer": "^5.5.0",
"commander": "^2.15.0",
"ieee754": "^1.1.8",
"iso-url": "~0.4.4",
"json-text-sequence": "~0.1.0"
"ieee754": "^1.1.13",
"iso-url": "~0.4.7",
"json-text-sequence": "~0.1.0",
"readable-stream": "^3.6.0"
},
"engines": {
"node": ">=4"
Expand Down
23 changes: 12 additions & 11 deletions src/commented.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* eslint-disable */
'use strict'

const stream = require('stream')
const util = require('util')
const utils = require('./utils')
const Simple = require('./simple')
const { Buffer } = require('buffer')
const stream = require('readable-stream')
const Decoder = require('./decoder')
const constants = require('./constants')
const bignumber = require('bignumber.js').BigNumber

const MT = constants.MT,
NUMBYTES = constants.NUMBYTES,
SYMS = constants.SYMS
const MT = constants.MT

const NUMBYTES = constants.NUMBYTES

const SYMS = constants.SYMS

function plural (c) {
if (c > 1) {
Expand Down Expand Up @@ -42,7 +43,7 @@ class Commented extends stream.Transform {

this.depth = 1
this.max_depth = max_depth
this.all = new NoFilter
this.all = new NoFilter()
this.parser = new Decoder(options)
this.parser.on('value', this._on_value.bind(this))
this.parser.on('start', this._on_start.bind(this))
Expand Down Expand Up @@ -114,7 +115,7 @@ class Commented extends stream.Transform {
default:
throw new Error('Unknown option type')
}
const bs = new NoFilter
const bs = new NoFilter()
const d = new Commented({
max_depth: max_depth
})
Expand Down Expand Up @@ -294,7 +295,7 @@ class Commented extends stream.Transform {
this.push('undefined\n')
} else if (typeof val === 'string') {
this.depth--
if (val.length > 0 ) {
if (val.length > 0) {
this.push(JSON.stringify(val))
this.push('\n')
}
Expand All @@ -308,7 +309,7 @@ class Commented extends stream.Transform {
this.push(val.toString())
this.push('\n')
} else {
this.push(util.inspect(val))
this.push(JSON.stringify(val))
this.push('\n')
}

Expand Down
2 changes: 2 additions & 0 deletions src/decoder.asm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

module.exports = function decodeAsm (stdlib, foreign, buffer) {
'use asm'

Expand Down
4 changes: 3 additions & 1 deletion src/decoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { Buffer } = require('buffer')
const ieee754 = require('ieee754')
const Bignumber = require('bignumber.js').BigNumber

Expand Down Expand Up @@ -55,6 +56,7 @@ class Decoder {

// Initialize asm based parser
this.parser = parser(global, {
// eslint-disable-next-line no-console
log: console.log.bind(console),
pushInt: this.pushInt.bind(this),
pushInt32: this.pushInt32.bind(this),
Expand Down Expand Up @@ -327,7 +329,7 @@ class Decoder {
}

createUndefined () {
return void 0
return undefined
}

createInfinity () {
Expand Down
1 change: 1 addition & 0 deletions src/diagnose.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { Buffer } = require('buffer')
const Decoder = require('./decoder')
const utils = require('./utils')

Expand Down
5 changes: 3 additions & 2 deletions src/encoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { Buffer } = require('buffer')
const { URL } = require('iso-url')
const Bignumber = require('bignumber.js').BigNumber

Expand Down Expand Up @@ -254,7 +255,7 @@ class Encoder {
if (!gen._pushInt(obj.size, MT.ARRAY)) {
return false
}
for (let x of obj) {
for (const x of obj) {
if (!gen.pushAny(x)) {
return false
}
Expand Down Expand Up @@ -425,7 +426,7 @@ class Encoder {
case SYMS.NULL:
return this._pushObject(null)
case SYMS.UNDEFINED:
return this._pushUndefined(void 0)
return this._pushUndefined(undefined)
// TODO: Add pluggable support for other symbols
default:
throw new Error('Unknown symbol: ' + obj.toString())
Expand Down
2 changes: 1 addition & 1 deletion src/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Simple {
}
case SIMPLE.UNDEFINED:
if (hasParent) {
return void 0
return undefined
} else {
return SYMS.UNDEFINED
}
Expand Down
2 changes: 1 addition & 1 deletion src/tagged.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Tagged {
*/
convert (converters) {
var er, f
f = converters != null ? converters[this.tag] : void 0
f = converters != null ? converters[this.tag] : undefined
if (typeof f !== 'function') {
f = Tagged['_tag' + this.tag]
if (typeof f !== 'function') {
Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { Buffer } = require('buffer')
const Bignumber = require('bignumber.js').BigNumber

const constants = require('./constants')
Expand Down
Loading