diff options
Diffstat (limited to 'node_modules/unique-slug')
| -rw-r--r-- | node_modules/unique-slug/.travis.yml | 11 | ||||
| -rw-r--r-- | node_modules/unique-slug/LICENSE | 15 | ||||
| -rw-r--r-- | node_modules/unique-slug/README.md | 20 | ||||
| -rw-r--r-- | node_modules/unique-slug/index.js | 19 | ||||
| -rw-r--r-- | node_modules/unique-slug/package.json | 23 | ||||
| -rw-r--r-- | node_modules/unique-slug/test/index.js | 13 |
6 files changed, 101 insertions, 0 deletions
diff --git a/node_modules/unique-slug/.travis.yml b/node_modules/unique-slug/.travis.yml new file mode 100644 index 00000000..3bc5d90c --- /dev/null +++ b/node_modules/unique-slug/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +sudo: false +before_install: + - "npm -g install npm" +node_js: + - "0.8" + - "0.10" + - "0.12" + - "iojs" + - "4" + - "5" diff --git a/node_modules/unique-slug/LICENSE b/node_modules/unique-slug/LICENSE new file mode 100644 index 00000000..7953647e --- /dev/null +++ b/node_modules/unique-slug/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright npm, Inc + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/unique-slug/README.md b/node_modules/unique-slug/README.md new file mode 100644 index 00000000..52de4277 --- /dev/null +++ b/node_modules/unique-slug/README.md @@ -0,0 +1,20 @@ +unique-slug +=========== + +Generate a unique character string suitible for use in files and URLs. + +``` +var uniqueSlug = require('unique-slug') + +var randomSlug = uniqueSlug() +var fileSlug = uniqueSlug('/etc/passwd') +``` + +### uniqueSlug(*str*) → String (8 chars) + +If *str* is passed in then the return value will be its murmur hash in +hex. + +If *str* is not passed in, it will be 4 bytes coverted into 8 hex +characters, generated by `crypto.pseudoRandomBytes`. + diff --git a/node_modules/unique-slug/index.js b/node_modules/unique-slug/index.js new file mode 100644 index 00000000..7c5d6c75 --- /dev/null +++ b/node_modules/unique-slug/index.js @@ -0,0 +1,19 @@ +'use strict' +var crypto = require('crypto') +var MurmurHash3 = require('imurmurhash') + +module.exports = function (uniq) { + if (uniq) { + var hash = new MurmurHash3(uniq) + return ('00000000' + hash.result().toString(16)).substr(-8) + } else { + // Called without a callback, because this interface should neither block + // nor error (by contrast with randomBytes which will throw an exception + // without enough entropy). + // + // However, due to a change in Node 0.10.27+, pseudoRandomBytes is now the + // same as randomBytes, and may in fact block in situations where + // insufficent entropy is available. + return crypto.pseudoRandomBytes(4).toString('hex') + } +} diff --git a/node_modules/unique-slug/package.json b/node_modules/unique-slug/package.json new file mode 100644 index 00000000..ef7d2b4a --- /dev/null +++ b/node_modules/unique-slug/package.json @@ -0,0 +1,23 @@ +{ + "name": "unique-slug", + "version": "2.0.1", + "description": "Generate a unique character string suitible for use in files and URLs.", + "main": "index.js", + "scripts": { + "test": "standard && tap --coverage test" + }, + "keywords": [], + "author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org)", + "license": "ISC", + "devDependencies": { + "standard": "^5.4.1", + "tap": "^2.3.1" + }, + "repository": { + "type": "git", + "url": "git://github.com/iarna/unique-slug.git" + }, + "dependencies": { + "imurmurhash": "^0.1.4" + } +} diff --git a/node_modules/unique-slug/test/index.js b/node_modules/unique-slug/test/index.js new file mode 100644 index 00000000..0f4ccad0 --- /dev/null +++ b/node_modules/unique-slug/test/index.js @@ -0,0 +1,13 @@ +'use strict' +var t = require('tap') +var uniqueSlug = require('../index.js') + +t.plan(5) +var slugA = uniqueSlug() +t.is(slugA.length, 8, 'random slugs are 8 chars') +t.notEqual(slugA, uniqueSlug(), "two slugs aren't the same") +var base = '/path/to/thingy' +var slugB = uniqueSlug(base) +t.is(slugB.length, 8, 'string based slugs are 8 chars') +t.is(slugB, uniqueSlug(base), 'two string based slugs, from the same string are the same') +t.notEqual(slugB, uniqueSlug(slugA), 'two string based slongs, from diff strings are different') |
