Skip to content

Commit e55d941

Browse files
authored
Merge pull request #11 from slacroix/feature-tedious
Removed dependency on seriate. Now uses tedious directly.
2 parents ba1e780 + c1cd4a1 commit e55d941

23 files changed

+1678
-1150
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NHibernate-style hi/lo ID generator for node.js
66

77
### Requiring & Configuring
88

9-
node-hilo exports a factory function that takes an instance of [seriate](https://github.com/leankit-labs/seriate), and a configuration object:
9+
node-hilo exports a factory function that takes a configuration object:
1010
```javascript
1111
/*
1212
The configuration argument can contain the following:
@@ -23,23 +23,18 @@ node-hilo exports a factory function that takes an instance of [seriate](https:/
2323
}
2424
}
2525
*/
26-
var hilo = require( "node-hilo" )( seriate, configuration );
26+
var hilo = require( "node-hilo" )( configuration );
2727
```
2828

2929
### How to Use
3030

31-
node-hilo exports two module members: a `nextId` method and a read-only property called `hival`. You will likely *never* need to care about the `hival` value - it's there for diagnostics and testing. The `nextId` method returns a promise, with the newly generated ID being passed to the success callback:
31+
node-hilo exports three module members: a `nextId` method, a `nextIds` method and a read-only property called `hival`. You will likely *never* need to care about the `hival` value - it's there for diagnostics and testing. The `nextId` method returns a promise, with the newly generated ID being passed to the success callback:
3232

3333
```javascript
34-
hilo.nextId(
35-
function( id ){
36-
// Now you can use the id on your object, etc.
37-
api.saveNewThing( id, newThing );
38-
},
39-
function( err) {
40-
console.log( "O NOES!", err );
41-
}
42-
);
34+
const id = await hilo.nextId();
35+
36+
// block of 100 ids
37+
const ids = await hilo.nextIds( 100 )
4338
```
4439

4540
## The More You Know...

package-lock.json

Lines changed: 743 additions & 613 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,24 @@
4040
"cover:show": "open \"file://$PWD/coverage/index.html\""
4141
},
4242
"dependencies": {
43-
"big-integer": "^1.4.4",
44-
"lodash": "^4.17.10",
45-
"machina": "^2.0.2"
43+
"big-integer": "^1.6.40",
44+
"lodash": "^4.17.11",
45+
"machina": "^4.0.2",
46+
"tedious": "^4.1.1"
4647
},
4748
"devDependencies": {
48-
"chai": "^4.1.2",
49+
"chai": "^4.2.0",
4950
"chai-as-promised": "^7.1.1",
51+
"dirty-chai": "^2.0.1",
5052
"eslint": "^4.19.1",
5153
"eslint-config-leankit": "^4.5.0",
5254
"mocha": "^5.2.0",
53-
"nodemon": "^1.17.5",
54-
"nyc": "^11.8.0",
55+
"nodemon": "^1.18.7",
56+
"nyc": "^11.9.0",
5557
"processhost": "^0.2.1",
56-
"proxyquire": "^2.0.1",
57-
"seriate": "^0.13.1",
58-
"sinon": "^5.0.10",
59-
"sinon-chai": "^3.1.0"
58+
"proxyquire": "^2.1.0",
59+
"sinon": "^5.1.1",
60+
"sinon-chai": "^3.3.0"
6061
},
6162
"engines": {
6263
"node": ">=8.0.0"

spec/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
bigInt: true,
1414
should: true,
1515
getExpected: true,
16-
getHiloInstance: true
16+
proxyquire: true,
17+
expect: true
1718
}
1819
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
describe( "HiloGenerationError", () => {
2+
let subject;
3+
4+
beforeEach( () => {
5+
const HiloGenerationError = require( "../../src/HiloGenerationError" );
6+
subject = new HiloGenerationError( "MESSAGE" );
7+
} );
8+
9+
it( "should set the error message", () => {
10+
subject.message.should.eql( "MESSAGE" );
11+
} );
12+
13+
it( "should set the error name", () => {
14+
subject.name.should.eql( "HiloGenerationError" );
15+
} );
16+
} );
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
describe( "createTediousConfig", () => {
2+
let subject;
3+
beforeEach( () => {
4+
subject = require( "../../src/createTediousConfig" );
5+
} );
6+
7+
it( "should set all properties", () => {
8+
subject( {
9+
user: "USER",
10+
password: "PASSWORD",
11+
server: "SERVER",
12+
domain: "DOMAIN",
13+
host: "HOST",
14+
port: "PORT",
15+
database: "DATABASE",
16+
connectTimeout: "CONNECTTIMEOUT",
17+
requestTimeout: "REQUESTTIMEOUT",
18+
encrypt: "ENCRYPT"
19+
} ).should.eql( {
20+
server: "SERVER",
21+
authentication: {
22+
type: "ntlm",
23+
options: {
24+
userName: "USER",
25+
password: "PASSWORD",
26+
domain: "DOMAIN"
27+
}
28+
},
29+
options: {
30+
port: "PORT",
31+
database: "DATABASE",
32+
connectTimeout: "CONNECTTIMEOUT",
33+
requestTimeout: "REQUESTTIMEOUT",
34+
encrypt: "ENCRYPT",
35+
rowCollectionOnRequestCompletion: true,
36+
useColumnNames: true,
37+
abortTransactionOnError: true
38+
}
39+
} );
40+
} );
41+
42+
it( "should set the auth to default when domain is not provided", () => {
43+
subject( {} ).authentication.type.should.eql( "default" );
44+
} );
45+
46+
it( "should set the server name from the host when server is not provided", () => {
47+
subject( { host: "HOST" } ).server.should.eql( "HOST" );
48+
} );
49+
} );

0 commit comments

Comments
 (0)