diff --git a/README.md b/README.md index 0c02c00..0f01305 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ console.log(thinid()); ``` ```sh -Output should be '3ywbk3e0-7825-e798-90ee-948s2lmw82bd' +Output should be '171a7-0688a_69261' ``` ## Contributors diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index a9dcd8e..078ca8b 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -1,3 +1,7 @@ +import thinid from '../src'; + test('Thinid Test', () => { - expect('thinid').toBe('thinid'); + const id = thinid(); + expect(id).toHaveLength(17); + expect(typeof id).toEqual('string'); }); diff --git a/package.json b/package.json index cfc5b34..74d8313 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thinid", - "version": "0.1.0", + "version": "0.2.0", "description": "🚀📦 Create 🆔 unique ID like eating 🥞 pancakes.", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/index.ts b/src/index.ts index ca0ad35..6391237 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,9 @@ -console.log('thinid'); +function s4() { + return Math.floor(new Date().getTime() * Math.random()) + .toString(16) + .substr(1, 5); +} + +export default function thinid() { + return s4() + '-' + s4() + '_' + s4(); +}