s-yadav / flakeid Goto Github PK
View Code? Open in Web Editor NEWTwittter Snowflake like unique id generator plugin for nodejs and browser
License: MIT License
Twittter Snowflake like unique id generator plugin for nodejs and browser
License: MIT License
I'm trying to include it in-browser.
I downloaded the minified file, included it in my file header, and tried to call
new FlakeId().gen()
but I get
Uncaught TypeError: FlakeId is not a constructor
How am I supposed to use it?
This code in flakeid.js
const a = {
b: c,
d: 2
}
//const d = {...a};
is causing the following errors when trying to use in node.js
$ npm test
> [email protected] test C:\Users\tom\code\digitizer-apex
> mocha --colors --recursive --require ts-node/register --watch-extensions ts "**/*spec.ts"
C:\Users\tom\code\digitizer-apex\node_modules\flakeid\lib\flakeid.js:68
b: c,
^
ReferenceError: c is not defined
at FlakeId.gen (C:\Users\tom\code\digitizer-apex\node_modules\flakeid\lib\flakeid.js:68:12)
at Object.get (C:\Users\tom\code\digitizer-apex\src\util\mockId.ts:24:29)
at Object.<anonymous> (C:\Users\tom\code\digitizer-apex\src\util\mockId.spec.ts:6:20)
at Module._compile (module.js:643:30)
at Module.m._compile (C:\Users\tom\code\digitizer-apex\node_modules\ts-node\src\index.ts:430:23)
at Module._extensions..js (module.js:654:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\tom\code\digitizer-apex\node_modules\ts-node\src\index.ts:433:12)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at C:\Users\tom\code\digitizer-apex\node_modules\mocha\lib\mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (C:\Users\tom\code\digitizer-apex\node_modules\mocha\lib\mocha.js:247:14)
at Mocha.run (C:\Users\tom\code\digitizer-apex\node_modules\mocha\lib\mocha.js:576:10)
at Object.<anonymous> (C:\Users\tom\code\digitizer-apex\node_modules\mocha\bin\_mocha:637:18)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! Test failed. See above for more details.
This seems like cruft code that can be removed.
It would be great to have a bigint return type if user wants to. It is not possible for me to cast integer from id.gen() to bigint in mongodb.
Thanks a lot for this package. However I gained a huge performance boost if instead of returning hexToDec(hex), BigInt(hex).
For comparison BigInt constructor yields around 0.05 ms consistently. Whereas hexToDec yields around 0.35 ms - 0.9 ms varying randomly. A BigInt constructor with fallback to hexToDec would be great, I can do it if you want to
When bid is "1100000010000101111100010101000010011111000000000000"
It ends up the id
became null
The for
statement is for (var i = bid.length; i >= 0; i -= 4)
I think it should be for (var i = bid.length; i > 0; i -= 4)
Is this module stable? Would it be appropriate to bump the major version to 1.0.0?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.