Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-05-22 11:33:46 +0300
committerRebecca Turner <me@re-becca.org>2015-06-26 03:27:03 +0300
commitd3c858ce4cfb3aee515bb299eb034fe1b5e44344 (patch)
treee7714c839934a729b68038f4c7dc5ec3ed877638 /node_modules/unique-slug
parent24564b9654528d23c726cf9ea82b1aef2044b692 (diff)
deps: deduplicate npm@3 style
Diffstat (limited to 'node_modules/unique-slug')
-rw-r--r--node_modules/unique-slug/.npmignore5
-rw-r--r--node_modules/unique-slug/README.md20
-rw-r--r--node_modules/unique-slug/index.js15
-rw-r--r--node_modules/unique-slug/package.json74
-rw-r--r--node_modules/unique-slug/test/index.js13
5 files changed, 127 insertions, 0 deletions
diff --git a/node_modules/unique-slug/.npmignore b/node_modules/unique-slug/.npmignore
new file mode 100644
index 000000000..1ab9fa63f
--- /dev/null
+++ b/node_modules/unique-slug/.npmignore
@@ -0,0 +1,5 @@
+*~
+.#*
+DEADJOE
+
+node_modules
diff --git a/node_modules/unique-slug/README.md b/node_modules/unique-slug/README.md
new file mode 100644
index 000000000..978f69b72
--- /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 (32 chars)
+
+If *str* is passed in then the return value will be its md5 digest in
+hex.
+
+If *str* is not passed in, it will be 16 bytes coverted into 32 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 000000000..747cf6d06
--- /dev/null
+++ b/node_modules/unique-slug/index.js
@@ -0,0 +1,15 @@
+'use strict'
+var crypto = require('crypto')
+
+module.exports = function (uniq) {
+ if (uniq) {
+ var hash = crypto.createHash('md5')
+ hash.update(uniq)
+ return hash.digest('hex')
+ } else {
+ // Safe because w/o a callback because this interface can
+ // neither block nor error (by contrast with randomBytes
+ // which will throw an exception without enough entropy)
+ return crypto.pseudoRandomBytes(16).toString('hex')
+ }
+}
diff --git a/node_modules/unique-slug/package.json b/node_modules/unique-slug/package.json
new file mode 100644
index 000000000..959233482
--- /dev/null
+++ b/node_modules/unique-slug/package.json
@@ -0,0 +1,74 @@
+{
+ "_args": [
+ [
+ "unique-slug@^1.0.0",
+ "/Users/rebecca/code/npm/node_modules/unique-filename"
+ ]
+ ],
+ "_from": "unique-slug@>=1.0.0 <2.0.0",
+ "_id": "unique-slug@1.0.0",
+ "_inCache": true,
+ "_location": "/unique-slug",
+ "_nodeVersion": "1.6.2",
+ "_npmUser": {
+ "email": "me@re-becca.org",
+ "name": "iarna"
+ },
+ "_npmVersion": "2.7.6",
+ "_phantomChildren": {},
+ "_requested": {
+ "name": "unique-slug",
+ "raw": "unique-slug@^1.0.0",
+ "rawSpec": "^1.0.0",
+ "scope": null,
+ "spec": ">=1.0.0 <2.0.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/unique-filename"
+ ],
+ "_shasum": "4459d12416f576cc091a3deb19939ec99c735626",
+ "_shrinkwrap": null,
+ "_spec": "unique-slug@^1.0.0",
+ "_where": "/Users/rebecca/code/npm/node_modules/unique-filename",
+ "author": {
+ "email": "me@re-becca.org",
+ "name": "Rebecca Turner",
+ "url": "http://re-becca.org"
+ },
+ "bugs": {
+ "url": "https://github.com/iarna/unique-slug/issues"
+ },
+ "dependencies": {},
+ "description": "Generate a unique character string suitible for use in files and URLs.",
+ "devDependencies": {
+ "standard": "^3.7.3",
+ "tap": "^1.0.0"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "4459d12416f576cc091a3deb19939ec99c735626",
+ "tarball": "http://registry.npmjs.org/unique-slug/-/unique-slug-1.0.0.tgz"
+ },
+ "gitHead": "024b3bd3c0184550702c93f088822e3f38da5c17",
+ "homepage": "https://github.com/iarna/unique-slug",
+ "keywords": [],
+ "license": "ISC",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "iarna",
+ "email": "me@re-becca.org"
+ }
+ ],
+ "name": "unique-slug",
+ "optionalDependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/iarna/unique-slug.git"
+ },
+ "scripts": {
+ "test": "standard && tap test"
+ },
+ "version": "1.0.0"
+}
diff --git a/node_modules/unique-slug/test/index.js b/node_modules/unique-slug/test/index.js
new file mode 100644
index 000000000..6866678ed
--- /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, 32, 'random slugs are 32 chars')
+t.notEqual(slugA, uniqueSlug(), "two slugs aren't the same")
+var base = '/path/to/thingy'
+var slugB = uniqueSlug(base)
+t.is(slugB.length, 32, 'string based slugs are 32 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')