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