Browse Source

修改demo程序的一个错误

tags/v1.3.1
zhupengfei 3 years ago
parent
commit
872cd6a34d
3 changed files with 15 additions and 5 deletions
  1. +6
    -5
      TypeScript/README.md
  2. +9
    -0
      TypeScript/test/test1.ts
  3. +0
    -0
      TypeScript/test/tests.ts

+ 6
- 5
TypeScript/README.md View File

@@ -11,8 +11,6 @@


```bash ```bash
ts-node test/test.ts 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 ```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) 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/tests.ts View File


Loading…
Cancel
Save