Skip to content

Commit

Permalink
feat(pick): use RandomGenerator as the base class
Browse files Browse the repository at this point in the history
  • Loading branch information
richrdkng committed Aug 19, 2023
1 parent 67b0099 commit d4e635c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
51 changes: 33 additions & 18 deletions packages/pick/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/pick/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@
"@types/semantic-release": "^20.0.1",
"jest": "^29.6.2",
"jest-extended": "^4.0.1",
"rollup": "^3.26.3",
"rollup": "^3.28.0",
"semantic-release": "^19.0.5",
"semantic-release-monorepo": "^7.0.5",
"snazzy": "^9.0.0",
"string-dedent": "^3.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-standard": "^12.0.2",
"tslib": "^2.6.0",
"tslib": "^2.6.2",
"typescript": "^4.9.4"
},
"dependencies": {
"@grandom/core": "^1.6.0",
"@grandom/engines": "^1.0.2"
"@grandom/core": "^2.4.0",
"@grandom/engines": "^2.1.0"
}
}
25 changes: 12 additions & 13 deletions packages/pick/src/RandomPick/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

// TODO: include / exclude / filter function
// TODO: implement edge cases (including infinite loops)

import { RandomEngine } from '@grandom/core'
import { RandomGenerator } from '@grandom/core'

const DEFAULT_FALLBACK = undefined

Expand Down Expand Up @@ -82,20 +81,20 @@ const unique = grandom.pick.multiple.unique([1, 2, 3], { count: 2, default: -1 }
// }
// }

export default class RandomPick {
private readonly _engine: RandomEngine
export default class RandomPick extends RandomGenerator {
// private readonly _engine: RandomEngine

constructor (engine: RandomEngine) {
this._engine = engine
// constructor (engine: RandomEngine) {
// this._engine = engine

// const pick: Pick = (arg1: any, arg2?: any): any => {}
// pick.multiple = (arg1: any, arg2: any): any => {}
// // pick.multiple.unique = (arg1: any, arg2?: any): any => { return () => null }
// pick.unique = (arg1: any, arg2?: any) => { return (): any => null }
// pick.unique.multiple = (arg1: any, arg2: any) => { return (): any => null }
// // const pick: Pick = (arg1: any, arg2?: any): any => {}
// // pick.multiple = (arg1: any, arg2: any): any => {}
// // // pick.multiple.unique = (arg1: any, arg2?: any): any => { return () => null }
// // pick.unique = (arg1: any, arg2?: any) => { return (): any => null }
// // pick.unique.multiple = (arg1: any, arg2: any) => { return (): any => null }

// this.pick = pick
}
// // this.pick = pick
// }

// pick: Pick

Expand Down
2 changes: 1 addition & 1 deletion packages/pick/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BasicEngine } from '@grandom/engines'
import BasicEngine from '@grandom/engines/basic'
import RandomPick from './RandomPick'

const random = new RandomPick(new BasicEngine())
Expand Down

0 comments on commit d4e635c

Please sign in to comment.