Skip to content

Commit e4326bd

Browse files
committed
updates
1 parent fa4fbf1 commit e4326bd

8 files changed

Lines changed: 28 additions & 10 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ src/**.js
77
coverage
88
*.log
99
yarn.lock
10-
.vscode
10+
.vscode/*
11+
!.vscode/settings.json
1112
docs/
13+
*.tgz

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cSpell.words": [
3+
"hexa",
4+
"lcase",
5+
"Randomator",
6+
"ucase"
7+
]
8+
}

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ CHANGELOG
22
=========
33

44
## HEAD (Unreleased)
5-
_(none)_
5+
6+
* updated options inputs into to built in generators
7+
* fixed build issues where a type was missing
8+
* added `.$` getter to return a bound generator function
69

710
---
811

912
## 1.0.0 (2021-04-25)
10-
_(none)_
13+
* initial release
1114

12-
## 1.0.0 (2021-01-26)
15+
## 0.0.0 (2021-01-26)
1316

1417
* added changelog
1518

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "randomator",
33
"private": false,
44
"version": "1.0.0",
5-
"description": "composible random generators",
5+
"description": "composable random generators",
66
"main": "build/main/index.js",
77
"typings": "build/main/index.d.ts",
88
"module": "build/module/index.js",
@@ -23,6 +23,7 @@
2323
"watch:build": "tsc -p tsconfig.json -w",
2424
"watch:test": "jest --watch",
2525
"version": "chg release -y && git add -A CHANGELOG.md",
26+
"prepare": "run-s build",
2627
"np": "np",
2728
"check": "run-s test:lint test:prettier",
2829
"coverage": "jest --coverage",

src/lib/generators/strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const ucase = char(UCASE);
2323
export const hexa = char('0123456789abcdef');
2424

2525
const DefaultStringOptions = {
26-
chars: char(),
26+
chars: char() as MaybeRandomator<string>,
2727
length: integer({ min: 5, max: 20 }) as MaybeRandomator<number>
2828
};
2929

src/lib/operators/core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ export function repeat<T>(arg: MaybeRandomator<T>, len: number, opts = { separat
170170
* @param args
171171
* @returns
172172
*/
173-
export function randomator<T>(
173+
export function randomator(
174174
strings: TemplateStringsArray | string[],
175-
...args: MaybeRandomator<T>[]
175+
...args: MaybeRandomator[]
176176
): Randomator<string> {
177-
const result: (MaybeRandomator<T> | string)[] = strings[0] ? [strings[0]] : [];
177+
const result: (MaybeRandomator | string)[] = strings[0] ? [strings[0]] : [];
178178
args.forEach((arg, i) => {
179179
result.push(arg);
180180
if (strings[i + 1]) {

src/lib/randomator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type MaybeRandomator<T = unknown> = T | Randomator<MaybeRandomator<T>>;
2+
export type GenerateFunction<T> = () => T;
23

34
export class Randomator<T = unknown> {
45
static from<U>(x: U | Randomator<U> | (() => U)): Randomator<U> {
@@ -20,6 +21,10 @@ export class Randomator<T = unknown> {
2021

2122
constructor(private _value: GenerateFunction<T>) {}
2223

24+
get $() {
25+
return this.value.bind(this);
26+
}
27+
2328
value(): T {
2429
let x = this._value();
2530
while (x instanceof Randomator) {

src/types/types.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)