From d29fd7875371a48f388a444c509602adebeea4bf Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 17 Jul 2017 17:01:10 +0200 Subject: [PATCH] refactor method names --- dist/index.d.ts | 6 +++--- dist/index.js | 8 ++++---- docs/index.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 13 +++++++++++++ test/test.ts | 11 ++++++++--- ts/index.ts | 6 +++--- 6 files changed, 76 insertions(+), 13 deletions(-) create mode 100644 docs/index.md diff --git a/dist/index.d.ts b/dist/index.d.ts index 30c4aa4..5255517 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,9 +1,9 @@ /** * returns short strings that are unique to very high degree od certainty */ -export declare let getShortId: () => string; +export declare let shortId: () => string; /** * returns strings that are unique to a very high degree of certainty */ -export declare let getUuidv4: () => string; -export declare let getUuidv5: (customStringArg: string, namespaceArg?: any) => string; +export declare let uuid4: () => string; +export declare let uuid5: (customStringArg: string, namespaceArg?: any) => string; diff --git a/dist/index.js b/dist/index.js index 577af69..e95777d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4,16 +4,16 @@ const plugins = require("./smartunique.plugins"); /** * returns short strings that are unique to very high degree od certainty */ -exports.getShortId = () => { +exports.shortId = () => { return plugins.shortid.generate(); }; /** * returns strings that are unique to a very high degree of certainty */ -exports.getUuidv4 = () => { +exports.uuid4 = () => { return plugins.uuidv4(); }; -exports.getUuidv5 = (customStringArg, namespaceArg = plugins.uuidv5.DNS) => { +exports.uuid5 = (customStringArg, namespaceArg = plugins.uuidv5.DNS) => { return plugins.uuidv5(customStringArg, namespaceArg); }; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGlEQUFnRDtBQUVoRDs7R0FFRztBQUNRLFFBQUEsVUFBVSxHQUFH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newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..48573a4 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,45 @@ +# smartunique +make things unique + +## Availabililty +[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartunique) +[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartunique) +[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartunique) +[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartunique/) + +## Status for master +[![build status](https://GitLab.com/pushrocks/smartunique/badges/master/build.svg)](https://GitLab.com/pushrocks/smartunique/commits/master) +[![coverage report](https://GitLab.com/pushrocks/smartunique/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartunique/commits/master) +[![npm downloads per month](https://img.shields.io/npm/dm/smartunique.svg)](https://www.npmjs.com/package/smartunique) +[![Dependency Status](https://david-dm.org/pushrocks/smartunique.svg)](https://david-dm.org/pushrocks/smartunique) +[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartunique/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartunique/master/dependencies/npm) +[![bitHound Code](https://www.bithound.io/github/pushrocks/smartunique/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartunique) +[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) +[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) + +## Usage +Use TypeScript for best in class instellisense. + +```javascript +// We are using TypeScript syntax here to have types in place +import * as smartunique from 'smartunique' + +// creates a short mathematically highly unique short string +let myShortid = smartunique.shortid() + +// creates a string that is possibly unique world wide +let myUuid4 = smartunique.uuid4() + +// creates a oneway repeatable unique id within a certain namespace +let myUuid5 = smartunique.uuid('myobscureduser@somedomain.com', smartunique.uuid4()) +``` + +Learn more about UUIDs: knowledgebase.gitzone.com/uuid.html + +For further information read the linked docs at the top of this README. + +> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) +| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) + +[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks) diff --git a/package.json b/package.json index d63e8ed..db76d77 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,19 @@ "scripts": { "test": "(npmts)" }, + "repository": { + "type": "git", + "url": "https://gitlab.com/pushrocks/smartunique.git" + }, + "keywords": [ + "unique", + "key", + "uuid", + "shortid", + "lossless", + "pushrocks", + "TypeScript" + ], "devDependencies": { "tapbundle": "^1.0.13" }, diff --git a/test/test.ts b/test/test.ts index e019a04..e8bc807 100644 --- a/test/test.ts +++ b/test/test.ts @@ -2,17 +2,22 @@ import { expect, tap } from 'tapbundle' import * as smartunique from '../dist/index' tap.test('should create shortid', async () => { - let result = smartunique.getShortId() + let result = smartunique.shortId() console.log(result) }) tap.test('should create uuidv4', async () => { - let result = smartunique.getUuidv4() + let result = smartunique.uuid4() console.log(result) }) tap.test('should create uuidv5', async () => { - let result = smartunique.getUuidv5('sometext') + let result = smartunique.uuid5('sometext') + console.log(result) +}) + +tap.test('should create uuidv5 within namespace', async () => { + let result = smartunique.uuid5('sometext', smartunique.uuid4()) console.log(result) }) diff --git a/ts/index.ts b/ts/index.ts index a811522..f23da31 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -3,17 +3,17 @@ import * as plugins from './smartunique.plugins' /** * returns short strings that are unique to very high degree od certainty */ -export let getShortId = (): string => { +export let shortId = (): string => { return plugins.shortid.generate() } /** * returns strings that are unique to a very high degree of certainty */ -export let getUuidv4 = (): string => { +export let uuid4 = (): string => { return plugins.uuidv4() } -export let getUuidv5 = (customStringArg: string, namespaceArg = plugins.uuidv5.DNS): string => { +export let uuid5 = (customStringArg: string, namespaceArg = plugins.uuidv5.DNS): string => { return plugins.uuidv5(customStringArg, namespaceArg) }