Browse Source

修正demo程序上的一个错误 (#14)

* 修改demo程序的一个错误

* 修正demo上一个错误
tags/v1.3.1
bonn GitHub 3 years ago
parent
commit
bdca240465
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions
  1. +7
    -6
      TypeScript/README.md
  2. +9
    -0
      TypeScript/test/test1.ts
  3. +0
    -0
      TypeScript/test/test2.ts

+ 7
- 6
TypeScript/README.md View File

@@ -10,9 +10,7 @@
执行测试代码

```bash
ts-node test/test.ts

NODE_ENV=development REDIS_HOST=127.0.0.1
ts-node test/test1.ts
```


@@ -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)

```


+ 9
- 0
TypeScript/test/test1.ts View File

@@ -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)

TypeScript/test/test.ts → TypeScript/test/test2.ts View File


Loading…
Cancel
Save