Skip to content

Commit 7203e96

Browse files
committed
feat: upgrade nan & deps
1 parent 5f23f49 commit 7203e96

11 files changed

Lines changed: 3713 additions & 87 deletions

.commitlintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
rules: {
3+
'body-leading-blank': [1, 'always'],
4+
'footer-leading-blank': [1, 'always'],
5+
'header-max-length': [2, 'always', 72],
6+
'scope-case': [2, 'always', 'lower-case'],
7+
'subject-case': [
8+
2,
9+
'never',
10+
['sentence-case', 'start-case', 'pascal-case', 'upper-case']
11+
],
12+
'subject-empty': [2, 'never'],
13+
'subject-full-stop': [2, 'never', '.'],
14+
'type-case': [2, 'always', 'lower-case'],
15+
'type-empty': [2, 'never'],
16+
'type-enum': [2, 'always', [
17+
'build',
18+
'ci',
19+
'docs',
20+
'feat',
21+
'fix',
22+
'perf',
23+
'refactor',
24+
'revert',
25+
'style',
26+
'test',
27+
'major',
28+
'minor',
29+
'patch',
30+
'chore'
31+
]
32+
]
33+
}
34+
};

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
module.exports = {
2-
"extends": "google"
2+
"extends": "makeomatic",
3+
"rules": {
4+
"no-bitwise": 0
5+
}
36
};

.releaserc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"branch": "master",
3+
"verifyConditions": ["@semantic-release/npm", "@semantic-release/github"],
4+
"analyzeCommits": {
5+
"preset": "angular",
6+
"releaseRules": [
7+
{ "type": "docs", "release": "patch" },
8+
{ "type": "refactor", "release": "patch" },
9+
{ "type": "style", "release": "patch" },
10+
{ "type": "minor", "release": "minor" },
11+
{ "type": "patch", "release": "patch" },
12+
{ "type": "major", "release": "major" },
13+
{ "type": "breaking", "release": "major" }
14+
]
15+
}
16+
}

lib/flakeless.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Flakeless = require('../build/Release/flakeless').Flakeless;
1+
const { Flakeless } = require('../build/Release/flakeless.node');
22

33
/**
44
* Represents an ID generator.

package.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
"id"
1111
],
1212
"scripts": {
13-
"pretest": "node_modules/.bin/eslint .",
14-
"test": "./node_modules/.bin/mocha",
15-
"install": "node-gyp rebuild"
13+
"pretest": "yarn lint",
14+
"lint": "eslint .",
15+
"test": "mocha",
16+
"install": "node-gyp rebuild",
17+
"semantic-release": "semantic-release",
18+
"commitmsg": "commitlint -e $GIT_PARAMS",
19+
"preparecommitmsg": "./node_modules/@makeomatic/deploy/git-hooks/prepare-commit-msg $GIT_PARAMS"
1620
},
1721
"repository": {
1822
"type": "git",
@@ -21,14 +25,18 @@
2125
"author": "Anthony Salani (https://github.com/asalani93)",
2226
"license": "MIT",
2327
"devDependencies": {
24-
"chai": "^3.5.0",
25-
"eslint": "^3.3.0",
26-
"eslint-config-google": "^0.6.0",
27-
"jsdoc": "^3.4.0",
28-
"mocha": "^3.0.2",
29-
"node-gyp": "^3.4.0"
28+
"@makeomatic/deploy": "^5.2.1",
29+
"babel-eslint": "^8.2.1",
30+
"chai": "^4.1.2",
31+
"eslint": "^4.17.0",
32+
"eslint-config-makeomatic": "^2.0.1",
33+
"eslint-plugin-import": "^2.8.0",
34+
"eslint-plugin-promise": "^3.6.0",
35+
"jsdoc": "^3.5.5",
36+
"mocha": "^5.0.0",
37+
"node-gyp": "^3.6.2"
3038
},
3139
"dependencies": {
32-
"nan": "^2.4.0"
40+
"nan": "^2.8.0"
3341
}
3442
}

src/flakeless.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void Flakeless::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
126126
const int argc = 1;
127127
v8::Local<v8::Value> argv[argc] = { info[0] };
128128
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
129-
info.GetReturnValue().Set(cons->NewInstance(argc, argv));
129+
info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
130130
}
131131
}
132132

test/.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
2-
"extends": "google",
2+
"extends": "makeomatic",
33
"env": {
44
"mocha": true
5+
},
6+
"rules": {
7+
"no-bitwise": 0
58
}
69
};

test/flakeless-10.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
'use strict';
2-
3-
const assert = require('chai').assert;
1+
const { assert } = require('chai');
42
const Flakeless = require('..');
53

6-
describe('Flakeless base10 output', function() {
7-
it('is an object', function() {
4+
describe('Flakeless base10 output', () => {
5+
it('is an object', () => {
86
const flakeless = new Flakeless({
9-
outputType: 'base10'
7+
outputType: 'base10',
108
});
119

1210
assert.equal(typeof flakeless, 'object');
1311
assert.instanceOf(flakeless, Flakeless);
1412
});
1513

16-
it('returns a string', function() {
14+
it('returns a string', () => {
1715
const flakeless = new Flakeless({
18-
outputType: 'base10'
16+
outputType: 'base10',
1917
});
2018

2119
const id = flakeless.next();
2220

2321
assert.typeOf(id, 'string');
2422
});
2523

26-
it('increases', function() {
24+
it('increases', () => {
2725
// Define a Flakeless counter that outputs in base10.
2826
const flakeless = new Flakeless({
2927
epochStart: Date.now(),
30-
outputType: 'base10'
28+
outputType: 'base10',
3129
});
3230

3331
// Generate a bunch of IDs.
3432
const ids = [];
35-
for (let i = 0; i < 1000; ++i) {
33+
for (let i = 0; i < 1000; i += 1) {
3634
ids.push(parseInt(flakeless.next(), 10));
3735
}
3836

@@ -42,67 +40,67 @@ describe('Flakeless base10 output', function() {
4240
assert.deepEqual(ids, sortedIds);
4341
});
4442

45-
it('is monotonic', function() {
43+
it('is monotonic', () => {
4644
const flakeless = new Flakeless({
4745
epochStart: Date.now(),
48-
outputType: 'base10'
46+
outputType: 'base10',
4947
});
5048

5149
// Generate a bunch of IDs.
5250
const ids = [];
53-
for (let i = 0; i < 1000; ++i) {
51+
for (let i = 0; i < 1000; i += 1) {
5452
ids.push(parseInt(flakeless.next(), 10));
5553
}
5654

5755
// Sort the IDs and remove duplicates. If the output is monotonic, the
5856
// length of the two array should be the same.
59-
const sortedIds = ids.sort().reduce(function(prev, curr) {
57+
const sortedIds = ids.sort().reduce((prev, curr) => {
6058
return (curr === prev[0]) ? prev : [curr].concat(prev);
6159
}, []);
6260
assert.lengthOf(sortedIds, 1000);
6361
});
6462

65-
it('has an encoded timestamp', function() {
63+
it('has an encoded timestamp', () => {
6664
const flakeless = new Flakeless({
6765
epochStart: Date.now() - 100,
6866
outputType: 'base10',
69-
workerID: 0x3ff
67+
workerID: 0x3ff,
7068
});
7169

7270
const id = flakeless.next();
7371

7472
assert.isAtLeast(id >> 22, 100);
7573
});
7674

77-
it('has an encoded worker ID', function() {
75+
it('has an encoded worker ID', () => {
7876
const flakeless = new Flakeless({
7977
epochStart: Date.now(),
8078
outputType: 'base10',
81-
workerID: 34
79+
workerID: 34,
8280
});
8381

8482
const id = flakeless.next();
8583

8684
assert.equal((id & 0x3ff000) >> 12, 34);
8785
});
8886

89-
it('has a properly sized workerID', function() {
87+
it('has a properly sized workerID', () => {
9088
const flakeless = new Flakeless({
9189
epochStart: Date.now(),
9290
outputType: 'base10',
93-
workerID: 0xffffffff
91+
workerID: 0xffffffff,
9492
});
9593

9694
const id = flakeless.next() >> 12;
9795

9896
assert.equal(id & 0x3ff, 0x3ff);
9997
});
10098

101-
it('has an encoded counter', function() {
99+
it('has an encoded counter', () => {
102100
const flakeless = new Flakeless({
103101
epochStart: Date.now(),
104102
outputType: 'base10',
105-
workerID: 0x3ff
103+
workerID: 0x3ff,
106104
});
107105

108106
const id = flakeless.next();

test/flakeless-16.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
1-
'use strict';
2-
3-
const assert = require('chai').assert;
1+
const { assert } = require('chai');
42
const Flakeless = require('..');
53

6-
describe('Flakeless base16 output', function() {
7-
it('is an object', function() {
4+
describe('Flakeless base16 output', () => {
5+
it('is an object', () => {
86
const flakeless = new Flakeless({
9-
outputType: 'base16'
7+
outputType: 'base16',
108
});
119

1210
assert.equal(typeof flakeless, 'object');
1311
assert.instanceOf(flakeless, Flakeless);
1412
});
1513

16-
it('returns a string', function() {
14+
it('returns a string', () => {
1715
const flakeless = new Flakeless({
18-
outputType: 'base16'
16+
outputType: 'base16',
1917
});
2018

2119
const id = flakeless.next();
2220

2321
assert.typeOf(id, 'string');
2422
});
2523

26-
it('is 16 characters long', function() {
24+
it('is 16 characters long', () => {
2725
const flakeless = new Flakeless({
28-
outputType: 'base16'
26+
outputType: 'base16',
2927
});
3028

3129
const id = flakeless.next();
3230

3331
assert.lengthOf(id, 16);
3432
});
3533

36-
it('increases', function() {
34+
it('increases', () => {
3735
// Define a Flakeless counter that outputs in base10.
3836
const flakeless = new Flakeless({
3937
epochStart: Date.now(),
40-
outputType: 'base16'
38+
outputType: 'base16',
4139
});
4240

4341
// Generate a bunch of IDs.
4442
const ids = [];
45-
for (let i = 0; i < 1000; ++i) {
43+
for (let i = 0; i < 1000; i += 1) {
4644
ids.push(flakeless.next());
4745
}
4846

@@ -52,67 +50,67 @@ describe('Flakeless base16 output', function() {
5250
assert.deepEqual(ids, sortedIds);
5351
});
5452

55-
it('is monotonic', function() {
53+
it('is monotonic', () => {
5654
const flakeless = new Flakeless({
5755
epochStart: Date.now(),
58-
outputType: 'base16'
56+
outputType: 'base16',
5957
});
6058

6159
// Generate a bunch of IDs.
6260
const ids = [];
63-
for (let i = 0; i < 1000; ++i) {
61+
for (let i = 0; i < 1000; i += 1) {
6462
ids.push(flakeless.next());
6563
}
6664

6765
// Sort the IDs and remove duplicates. If the output is monotonic, the
6866
// length of the two array should be the same.
69-
const sortedIds = ids.sort().reduce(function(prev, curr) {
67+
const sortedIds = ids.sort().reduce((prev, curr) => {
7068
return (curr === prev[0]) ? prev : [curr].concat(prev);
7169
}, []);
7270
assert.lengthOf(sortedIds, 1000);
7371
});
7472

75-
it('has an encoded timestamp', function() {
73+
it('has an encoded timestamp', () => {
7674
const flakeless = new Flakeless({
7775
epochStart: Date.now() - 100,
7876
outputType: 'base16',
79-
workerID: 0x3ff
77+
workerID: 0x3ff,
8078
});
8179

8280
const id = parseInt(flakeless.next(), 16);
8381

8482
assert.isAtLeast(id >> 22, 100);
8583
});
8684

87-
it('has an encoded worker ID', function() {
85+
it('has an encoded worker ID', () => {
8886
const flakeless = new Flakeless({
8987
epochStart: Date.now(),
9088
outputType: 'base16',
91-
workerID: 34
89+
workerID: 34,
9290
});
9391

9492
const id = parseInt(flakeless.next(), 16);
9593

9694
assert.equal((id & 0x3ff000) >> 12, 34);
9795
});
9896

99-
it('has a properly sized workerID', function() {
97+
it('has a properly sized workerID', () => {
10098
const flakeless = new Flakeless({
10199
epochStart: Date.now(),
102100
outputType: 'base16',
103-
workerID: 0xffffffff
101+
workerID: 0xffffffff,
104102
});
105103

106104
const id = parseInt(flakeless.next(), 16) >> 12;
107105

108106
assert.equal(id & 0x3ff, 0x3ff);
109107
});
110108

111-
it('has an encoded counter', function() {
109+
it('has an encoded counter', () => {
112110
const flakeless = new Flakeless({
113111
epochStart: Date.now(),
114112
outputType: 'base16',
115-
workerID: 0x3ff
113+
workerID: 0x3ff,
116114
});
117115

118116
const id = parseInt(flakeless.next(), 16);

0 commit comments

Comments
 (0)