Skip to content

Commit b3cf721

Browse files
fix: remove node globals
This PR remove node globals, updates deps and fixes lint problems. related to this ipfs/js-ipfs#2924
2 parents b6bae8b + 18e5342 commit b3cf721

30 files changed

+5437
-3872
lines changed

.dockerignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.jsdoc.conf

Lines changed: 0 additions & 18 deletions
This file was deleted.

.npmignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.travis.yml

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
1-
sudo: false
21
language: node_js
2+
cache: npm
3+
stages:
4+
- check
5+
- test
6+
- cov
37

4-
matrix:
5-
include:
6-
- node_js: 8
7-
env: CXX=g++-4.8
8-
- node_js: 10
9-
env:
10-
- SAUCE=true
11-
- CXX=g++-4.8
12-
- node_js: stable
13-
env: CXX=g++-4.8
8+
node_js:
9+
- '10'
10+
- '12'
11+
12+
os:
13+
- linux
14+
- osx
15+
- windows
1416

15-
script:
16-
- yarn lint
17-
- yarn test
18-
- yarn coverage
17+
script: npx nyc -s npm run test:node -- --bail
18+
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
19+
20+
jobs:
21+
include:
22+
- stage: check
23+
script:
24+
- npx aegir commitlint --travis
25+
- npx aegir dep-check
26+
- npm run lint
1927

20-
before_script:
21-
- export DISPLAY=:99.0
22-
- sh -e /etc/init.d/xvfb start
28+
- stage: test
29+
name: chrome
30+
addons:
31+
chrome: stable
32+
script: npx aegir test -t browser -t webworker
2333

24-
after_success:
25-
- yarn coverage-publish
34+
- stage: test
35+
name: firefox
36+
addons:
37+
firefox: latest
38+
script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
2639

27-
addons:
28-
firefox: 'latest'
29-
apt:
30-
sources:
31-
- ubuntu-toolchain-r-test
32-
packages:
33-
- g++-4.8
40+
notifications:
41+
email: false

.waiting.html

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![Coverage Status](https://coveralls.io/repos/github/dignifiedquire/borc/badge.svg?branch=master)](https://coveralls.io/github/dignifiedquire/borc?branch=master)
77
[![Dependency Status](https://david-dm.org/dignifiedquire/borc.svg?style=flat-square)](https://david-dm.org/dignifiedquire/borc)
88
[![Travis CI](https://travis-ci.org/dignifiedquire/borc.svg?branch=master)](https://travis-ci.org/dignifiedquire/borc)
9-
[![Circle CI](https://circleci.com/gh/dignifiedquire/borc.svg?style=svg)](https://circleci.com/gh/dignifiedquire/borc)
109

1110

1211
> 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**.

benchmarks/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
'use strict'
23

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

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

27-
let vecLength = vectors.length
28+
const vecLength = vectors.length
2829
let res = []
2930

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

4243
suite.add(`encode - stream - borc - ${vecLength}`, () => {
43-
const enc = new fastCbor.Encoder({ stream (chunk) {
44-
res.push(chunk)
45-
} })
44+
const enc = new fastCbor.Encoder({
45+
stream (chunk) {
46+
res.push(chunk)
47+
}
48+
})
4649
for (let i = 0; i < vecLength; i++) {
4750
enc.write(vectors[i].decoded)
4851
}

bin/cbor2comment

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
'use strict'
33

4-
const cbor = require('../src/cbor')
4+
const cbor = require('../src')
55
const utils = require('../src/utils')
66
const pkg = require('../package.json')
77

bin/cbor2diag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
'use strict'
33

4-
const cbor = require('../src/cbor')
4+
const cbor = require('../src')
55
const utils = require('../src/utils')
66
const pkg = require('../package.json')
77

bin/cbor2json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env node
2+
/* eslint-disable no-console */
23
'use strict'
34

4-
const cbor = require('../src/cbor')
5+
const cbor = require('../src')
56
const utils = require('../src/utils')
67
const pkg = require('../package.json')
78

bin/json2cbor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
'use strict'
33

4-
const cbor = require('../src/cbor')
4+
const cbor = require('../src')
55
const utils = require('../src/utils')
66
const pkg = require('../package.json')
77

circle.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"browser": {
1212
"fs": false
1313
},
14+
"files": [
15+
"src",
16+
"dist"
17+
],
1418
"scripts": {
1519
"test": "aegir test --files test/**/*.spec.js",
1620
"test:browser": "aegir test --target browser",
@@ -38,7 +42,8 @@
3842
"email": "[email protected]"
3943
},
4044
"devDependencies": {
41-
"aegir": "^18.0.1",
45+
"aegir": "^21.4.5",
46+
"ava": "^3.5.1",
4247
"benchmark": "^2.1.0",
4348
"budo": "^11.2.0",
4449
"cbor": "^4.0.0",
@@ -50,10 +55,12 @@
5055
"readmeFilename": "README.md",
5156
"dependencies": {
5257
"bignumber.js": "^9.0.0",
58+
"buffer": "^5.5.0",
5359
"commander": "^2.15.0",
54-
"ieee754": "^1.1.8",
55-
"iso-url": "~0.4.4",
56-
"json-text-sequence": "~0.1.0"
60+
"ieee754": "^1.1.13",
61+
"iso-url": "~0.4.7",
62+
"json-text-sequence": "~0.1.0",
63+
"readable-stream": "^3.6.0"
5764
},
5865
"engines": {
5966
"node": ">=4"

src/commented.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
/* eslint-disable */
12
'use strict'
23

3-
const stream = require('stream')
4-
const util = require('util')
5-
const utils = require('./utils')
6-
const Simple = require('./simple')
4+
const { Buffer } = require('buffer')
5+
const stream = require('readable-stream')
76
const Decoder = require('./decoder')
87
const constants = require('./constants')
98
const bignumber = require('bignumber.js').BigNumber
109

11-
const MT = constants.MT,
12-
NUMBYTES = constants.NUMBYTES,
13-
SYMS = constants.SYMS
10+
const MT = constants.MT
11+
12+
const NUMBYTES = constants.NUMBYTES
13+
14+
const SYMS = constants.SYMS
1415

1516
function plural (c) {
1617
if (c > 1) {
@@ -42,7 +43,7 @@ class Commented extends stream.Transform {
4243

4344
this.depth = 1
4445
this.max_depth = max_depth
45-
this.all = new NoFilter
46+
this.all = new NoFilter()
4647
this.parser = new Decoder(options)
4748
this.parser.on('value', this._on_value.bind(this))
4849
this.parser.on('start', this._on_start.bind(this))
@@ -114,7 +115,7 @@ class Commented extends stream.Transform {
114115
default:
115116
throw new Error('Unknown option type')
116117
}
117-
const bs = new NoFilter
118+
const bs = new NoFilter()
118119
const d = new Commented({
119120
max_depth: max_depth
120121
})
@@ -294,7 +295,7 @@ class Commented extends stream.Transform {
294295
this.push('undefined\n')
295296
} else if (typeof val === 'string') {
296297
this.depth--
297-
if (val.length > 0 ) {
298+
if (val.length > 0) {
298299
this.push(JSON.stringify(val))
299300
this.push('\n')
300301
}
@@ -308,7 +309,7 @@ class Commented extends stream.Transform {
308309
this.push(val.toString())
309310
this.push('\n')
310311
} else {
311-
this.push(util.inspect(val))
312+
this.push(JSON.stringify(val))
312313
this.push('\n')
313314
}
314315

src/decoder.asm.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable */
2+
13
module.exports = function decodeAsm (stdlib, foreign, buffer) {
24
'use asm'
35

src/decoder.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const { Buffer } = require('buffer')
34
const ieee754 = require('ieee754')
45
const Bignumber = require('bignumber.js').BigNumber
56

@@ -55,6 +56,7 @@ class Decoder {
5556

5657
// Initialize asm based parser
5758
this.parser = parser(global, {
59+
// eslint-disable-next-line no-console
5860
log: console.log.bind(console),
5961
pushInt: this.pushInt.bind(this),
6062
pushInt32: this.pushInt32.bind(this),
@@ -327,7 +329,7 @@ class Decoder {
327329
}
328330

329331
createUndefined () {
330-
return void 0
332+
return undefined
331333
}
332334

333335
createInfinity () {

src/diagnose.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const { Buffer } = require('buffer')
34
const Decoder = require('./decoder')
45
const utils = require('./utils')
56

src/encoder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const { Buffer } = require('buffer')
34
const { URL } = require('iso-url')
45
const Bignumber = require('bignumber.js').BigNumber
56

@@ -254,7 +255,7 @@ class Encoder {
254255
if (!gen._pushInt(obj.size, MT.ARRAY)) {
255256
return false
256257
}
257-
for (let x of obj) {
258+
for (const x of obj) {
258259
if (!gen.pushAny(x)) {
259260
return false
260261
}
@@ -425,7 +426,7 @@ class Encoder {
425426
case SYMS.NULL:
426427
return this._pushObject(null)
427428
case SYMS.UNDEFINED:
428-
return this._pushUndefined(void 0)
429+
return this._pushUndefined(undefined)
429430
// TODO: Add pluggable support for other symbols
430431
default:
431432
throw new Error('Unknown symbol: ' + obj.toString())

src/simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Simple {
8989
}
9090
case SIMPLE.UNDEFINED:
9191
if (hasParent) {
92-
return void 0
92+
return undefined
9393
} else {
9494
return SYMS.UNDEFINED
9595
}

src/tagged.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Tagged {
5858
*/
5959
convert (converters) {
6060
var er, f
61-
f = converters != null ? converters[this.tag] : void 0
61+
f = converters != null ? converters[this.tag] : undefined
6262
if (typeof f !== 'function') {
6363
f = Tagged['_tag' + this.tag]
6464
if (typeof f !== 'function') {

src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const { Buffer } = require('buffer')
34
const Bignumber = require('bignumber.js').BigNumber
45

56
const constants = require('./constants')

0 commit comments

Comments
 (0)