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

sequential-ids

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequential-ids - npm Package Compare versions

Comparing version 0.0.0-alpha.2.0 to 0.0.0-alpha.3.0

.npmingore

20

package.json
{
"name": "sequential-ids",
"version": "0.0.0-alpha.2.0",
"version": "0.0.0-alpha.3.0",
"description": "centralized generation of sequential, human-readable ids",
"homepage": "https://github.com/GochoMugo/sequential-ids",
"homepage": "https://github.com/forfuture-dev/node-sequential-ids",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/GochoMugo/sequential-ids.git"
"url": "https://github.com/forfuture-dev/node-sequential-ids.git"
},
"bugs": "https://github.com/GochoMugo/sequential-ids/issues",
"bugs": "https://github.com/forfuture-dev/node-sequential-ids/issues",
"keywords": [
"centralized",
"sequential",
"ids",
"sequence",
"human-readable",
"centralized"
"ids"
],
"author": {
"name": "Gocho Mugo",
"email": "mugo@forfuture.co.ke",
"url": "https://twitter.com/@mugo_gocho"
"name": "GochoMugo",
"email": "mugo@forfuture.co.ke"
},
"main": "sequential-ids.js",
"main": "index.js",
"dependencies": {}
}
# sequential ids
# node-sequential-ids
A [Node.js][nodejs] module that allows centralized generation of sequential, unique and human-readable ids.
A [Node.js][nodejs] module that allows centralized generation of
sequential and human-readable ids.
**Sample Id:** `ACB - 00423`
|Aspect|Detail|
|aspect|detail|
|-------|-----:|
|version|0.0.0-alpha.2.0|
|version|0.0.0-alpha.3.0|
|dependencies|none|
|last updated|4th Sept, 2014|
|last updated|29th Sept, 2014|
## installation
From [npmjs][npmjs]:
From [Npm][npmjs]:
$ npm install sequential-ids --save
```bash
$ npm install sequential-ids --save
```
## usage
```js
// assuming `db` is a variable holding a database connection with the
// method `.store(key, value)`
// assuming `db` is a variable holding a database object
// with the method `.store(key, value)`
// and `.read(key)`
var sequential = require("sequential-ids");
var generator = new sequential.Generator({
digits: 6, letters: 3,
store: function(ids) {
db.store("last-id", ids[ids.length - 1]);
},
restore: "AAB - 000"
});
var sequential = require("sequential-ids");
var generator = new sequential.Generator({
digits: 6,
letters: 3,
store: function (ids) {
db.store("last-id", ids[ids.length - 1]);
},
restore: (function () {
return db.read("last-id");
})()
});
var accessor = new sequential.Accessor()
accessor.next(function (id) {
console.log("First ID: " + id);
});
accessor.next(function (id) {
console.log("Second ID: " + id);
});
var accessor = new sequential.Accessor();
accessor.next(function(id) {
console.log("new id: %s", id);
});
```
## notes

@@ -84,5 +72,5 @@

* `digits` and `letters` will be ignored so as to follow the restore ID style.
* it must be in the same style as IDs generated by the Generator
* it **must** be in the same style as IDs generated by the Generator
* If not specified, generates from start.
* **MUST** be a string, or a function called that **returns** a string as in example above.
* **MUST** be a string.
* Defaults to `null`.

@@ -95,9 +83,9 @@ * `port`:

```js
```js
var sequential = require("sequential-ids");
var generatorA = new sequential.Generator({port: 8998});
var generatorB = new sequential.Generator({port: 7667});
var sequential = require("sequential-ids");
var generatorA = new sequential.Generator({port: 8998});
var generatorB = new sequential.Generator({port: 7667});
```
```

@@ -132,3 +120,3 @@

Copyright (c) 2014 Gocho Mugo <mugo@forfuture.co.ke>
Copyright (c) 2014 Forfuture LLC

@@ -135,0 +123,0 @@

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