From 872cd6a34d88d2844940c55b0b87f8c07da5ec01 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Mon, 4 Oct 2021 18:57:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9demo=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TypeScript/README.md | 11 ++++++----- TypeScript/test/test1.ts | 9 +++++++++ TypeScript/test/{test.ts => tests.ts} | 0 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 TypeScript/test/test1.ts rename TypeScript/test/{test.ts => tests.ts} (100%) diff --git a/TypeScript/README.md b/TypeScript/README.md index 1509999..1d12f9a 100644 --- a/TypeScript/README.md +++ b/TypeScript/README.md @@ -11,8 +11,6 @@ ```bash ts-node test/test.ts - -NODE_ENV=development REDIS_HOST=127.0.0.1 ``` @@ -20,11 +18,14 @@ NODE_ENV=development REDIS_HOST=127.0.0.1 ## 使用 ```js -import { Genid } from '../index' +import { snowflakeIdv1 } from '../snowflakeIdv1' + +const WorkerId = process.env.WorkerId == undefined ? 1 : process.env.WorkerId +const Method = process.env.Method == undefined ? 1 : process.env.Method -let gen = new Genid({ WorkerId: 1 }) -let id1 = gen.NextId() +let gen1 = new snowflakeIdv1({ WorkerId: WorkerId, Method: Method }) +let id1 = gen1.NextId() console.log(id1, id1.toString().length) ``` diff --git a/TypeScript/test/test1.ts b/TypeScript/test/test1.ts new file mode 100644 index 0000000..1957567 --- /dev/null +++ b/TypeScript/test/test1.ts @@ -0,0 +1,9 @@ +import { snowflakeIdv1 } from '../snowflakeIdv1' + +const WorkerId = process.env.WorkerId == undefined ? 1 : process.env.WorkerId + +const Method = process.env.Method == undefined ? 1 : process.env.Method + +let gen1 = new snowflakeIdv1({ WorkerId: WorkerId, Method: Method }) +let id1 = gen1.NextId() +console.log(id1, id1.toString().length) \ No newline at end of file diff --git a/TypeScript/test/test.ts b/TypeScript/test/tests.ts similarity index 100% rename from TypeScript/test/test.ts rename to TypeScript/test/tests.ts