pax_global_header00006660000000000000000000000064140325436420014515gustar00rootroot0000000000000052 comment=bbb5d66aa474cab942dfa5b412f74d9ac68b976d sindresorhus-unique-string-4caf69d/000077500000000000000000000000001403254364200175575ustar00rootroot00000000000000sindresorhus-unique-string-4caf69d/.editorconfig000066400000000000000000000002571403254364200222400ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 sindresorhus-unique-string-4caf69d/.gitattributes000066400000000000000000000000231403254364200224450ustar00rootroot00000000000000* text=auto eol=lf sindresorhus-unique-string-4caf69d/.github/000077500000000000000000000000001403254364200211175ustar00rootroot00000000000000sindresorhus-unique-string-4caf69d/.github/workflows/000077500000000000000000000000001403254364200231545ustar00rootroot00000000000000sindresorhus-unique-string-4caf69d/.github/workflows/main.yml000066400000000000000000000006451403254364200246300ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 14 - 12 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test sindresorhus-unique-string-4caf69d/.gitignore000066400000000000000000000000271403254364200215460ustar00rootroot00000000000000node_modules yarn.lock sindresorhus-unique-string-4caf69d/.npmrc000066400000000000000000000000231403254364200206720ustar00rootroot00000000000000package-lock=false sindresorhus-unique-string-4caf69d/index.d.ts000066400000000000000000000005551403254364200214650ustar00rootroot00000000000000/** Generate a unique random string. @returns A 32 character unique string. Matches the length of MD5, which is [unique enough](https://stackoverflow.com/a/2444336/64949) for non-crypto purposes. @example ``` import uniqueString from 'unique-string'; uniqueString(); //=> 'b4de2a49c8ffa3fbee04446f045483b2' ``` */ export default function uniqueString(): string; sindresorhus-unique-string-4caf69d/index.js000066400000000000000000000002151403254364200212220ustar00rootroot00000000000000import cryptoRandomString from 'crypto-random-string'; export default function uniqueString() { return cryptoRandomString({length: 32}); } sindresorhus-unique-string-4caf69d/index.test-d.ts000066400000000000000000000001541403254364200224350ustar00rootroot00000000000000import {expectType} from 'tsd'; import uniqueString from './index.js'; expectType(uniqueString()); sindresorhus-unique-string-4caf69d/license000066400000000000000000000021351403254364200211250ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. sindresorhus-unique-string-4caf69d/package.json000066400000000000000000000013671403254364200220540ustar00rootroot00000000000000{ "name": "unique-string", "version": "3.0.0", "description": "Generate a unique random string", "license": "MIT", "repository": "sindresorhus/unique-string", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "exports": "./index.js", "engines": { "node": ">=12" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "unique", "string", "random", "text", "id", "identifier", "slug", "hex" ], "dependencies": { "crypto-random-string": "^4.0.0" }, "devDependencies": { "ava": "^3.15.0", "tsd": "^0.14.0", "xo": "^0.38.2" } } sindresorhus-unique-string-4caf69d/readme.md000066400000000000000000000006271403254364200213430ustar00rootroot00000000000000# unique-string > Generate a unique random string ## Install ``` $ npm install unique-string ``` ## Usage ```js import uniqueString from 'unique-string'; uniqueString(); //=> 'b4de2a49c8ffa3fbee04446f045483b2' ``` ## API ### uniqueString() Returns a 32 character unique string. Matches the length of MD5, which is [unique enough](https://stackoverflow.com/a/2444336/64949) for non-crypto purposes. sindresorhus-unique-string-4caf69d/test.js000066400000000000000000000005351403254364200210770ustar00rootroot00000000000000import test from 'ava'; import uniqueString from './index.js'; test('main', t => { t.is(uniqueString().length, 32); const created = new Set(); for (let i = 0; i < 100000; i++) { const string = uniqueString(); if (created.has(string)) { t.fail(`${string} already exists`); } t.is(string.length, 32); created.add(string); } });