Socket
Socket
Sign inDemoInstall

cuid

Package Overview
Dependencies
0
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.3 to 2.1.4

.babelrc

21

package.json
{
"name": "cuid",
"version": "2.1.3",
"version": "2.1.4",
"description": "Collision-resistant ids optimized for horizontal scaling and performance. For node and browsers.",

@@ -29,14 +29,14 @@ "author": {

"devDependencies": {
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-register": "6.26.0",
"browserify": "16.2.2",
"eslint": "3.19.0",
"karma": "2.0.5",
"karma-browserify": "5.3.0",
"karma-chrome-launcher": "2.2.0",
"karma-tap": "4.1.4",
"eslint-plugin-testcafe": "0.2.1",
"mkdirp": "0.5.1",
"tape": "4.9.1",
"testcafe": "0.21.1",
"uglify-js": "3.4.7",
"updtr": "2.0.0",
"watchify": "3.11.0",
"webworkify": "1.5.0"
"watchify": "3.11.0"
},

@@ -47,7 +47,8 @@ "scripts": {

"test": "npm run lint && npm run test:server && npm run test:browser",
"test:browser": "karma start test/karma.conf.js",
"test:server": "tape test/**/*.js",
"test:browser": "testcafe chrome ./test/browser.js",
"test:server": "tape -r babel-register -r babel-polyfill test/server.js",
"prepare": "npm run build",
"update": "updtr"
}
},
"dependencies": {}
}

@@ -12,11 +12,22 @@ # cuid

Node style. For the browser, either bundle with something like [browserify](https://github.com/substack/node-browserify) or [webpack](http://webpack.github.io/), or use the stand-alone version and leave off the require line.
ESM:
```js
import cuid from 'cuid';
console.log( cuid() );
// cjld2cjxh0000qzrmn831i7rn
```
Node style:
```js
var cuid = require('cuid');
console.log( cuid() );
// ch72gsb320000udocl363eofy
// cjld2cyuq0000t3rmniod1foy
```
## Installing

@@ -23,0 +34,0 @@

@@ -1,9 +0,3 @@

var test = require('tape');
var cuid = require('../');
// browser check function adapted from is-in-browser module
var isInBrowser = typeof window === 'object' &&
typeof document === 'object' &&
document.nodeType === 9;
var MAX = 1200000;

@@ -33,46 +27,56 @@

test('cuid()', function (t) {
t.ok(typeof cuid() === 'string',
'cuid() should return a string.');
var defaultOptions = { isInBrowser: false };
t.end();
});
function run (test, options) {
var opt = Object.assign({}, defaultOptions, options);
test('cuid.slug()', function (t) {
t.ok(typeof cuid.slug() === 'string',
'cuid.slug() should return a string.');
test('cuid()', async t => {
await t.ok(typeof cuid() === 'string',
'cuid() should return a string.');
t.ok(collisionTest(cuid.slug),
'cuid.slug() cuids should not collide.');
await t.end();
});
t.end();
});
test('cuid.slug()', async t => {
await t.ok(typeof cuid.slug() === 'string',
'cuid.slug() should return a string.');
test('cuid.isCuid()', function (t) {
var id = cuid();
t.ok(cuid.isCuid(id) === true, 'cuid.isCuid() should return true for a valid cuid.');
t.ok(cuid.isCuid(null) === false, 'cuid.isCuid() should return false for null.');
t.ok(cuid.isCuid(undefined) === false, 'cuid.isCuid() should return false for undefined.');
t.ok(cuid.isCuid('abcdefghijklmnopqrstuvwxy') === false, 'cuid.isCuid() should return false for a random string.');
t.ok(cuid.isCuid(1) === false, 'cuid.isCuid() should return false for numbers.');
t.ok(cuid.isCuid(NaN) === false, 'cuid.isCuid() should return false for NaN.');
t.end();
});
await t.ok(collisionTest(cuid.slug),
'cuid.slug() cuids should not collide.');
test('cuid.isSlug()', function (t) {
var slug = cuid.slug();
t.ok(cuid.isSlug(slug) === true, 'cuid.isSlug() should return true for a valid cuid slug.');
t.ok(cuid.isSlug(null) === false, 'cuid.isSlug() should return false for null.');
t.ok(cuid.isSlug(undefined) === false, 'cuid.isSlug() should return false for undefined.');
t.ok(cuid.isSlug(1) === false, 'cuid.isSlug() should return false for numbers.');
t.ok(cuid.isSlug(NaN) === false, 'cuid.isSlug() should return false for NaN.');
t.end();
});
await t.end();
});
// perform collision test only if we aren't in the browser
test('cuid colissions', { skip: isInBrowser }, function (t) {
t.ok(collisionTest(cuid),
'cuids should not collide.');
test('cuid.isCuid()', async t => {
var id = cuid();
await t.ok(cuid.isCuid(id) === true, 'cuid.isCuid() should return true for a valid cuid.');
await t.ok(cuid.isCuid(null) === false, 'cuid.isCuid() should return false for null.');
await t.ok(cuid.isCuid(undefined) === false, 'cuid.isCuid() should return false for undefined.');
await t.ok(cuid.isCuid('abcdefghijklmnopqrstuvwxy') === false, 'cuid.isCuid() should return false for a random string.');
await t.ok(cuid.isCuid(1) === false, 'cuid.isCuid() should return false for numbers.');
await t.ok(cuid.isCuid(NaN) === false, 'cuid.isCuid() should return false for NaN.');
await t.end();
});
t.end();
});
test('cuid.isSlug()', async t => {
var slug = cuid.slug();
await t.ok(cuid.isSlug(slug) === true, 'cuid.isSlug() should return true for a valid cuid slug.');
await t.ok(cuid.isSlug(null) === false, 'cuid.isSlug() should return false for null.');
await t.ok(cuid.isSlug(undefined) === false, 'cuid.isSlug() should return false for undefined.');
await t.ok(cuid.isSlug(1) === false, 'cuid.isSlug() should return false for numbers.');
await t.ok(cuid.isSlug(NaN) === false, 'cuid.isSlug() should return false for NaN.');
await t.end();
});
// perform collision test only if we aren't in the browser
test('cuid colissions', { skip: opt.isInBrowser }, async t => {
await t.ok(collisionTest(cuid),
'cuids should not collide.');
await t.end();
});
}
module.exports = {
run: run
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc