main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[79a0317] | 1 | /**
|
---|
| 2 | * Returns a function that checks if an elements index matches the given rule
|
---|
| 3 | * highly optimized to return the fastest solution.
|
---|
| 4 | *
|
---|
| 5 | * @param parsed A tuple [a, b], as returned by `parse`.
|
---|
| 6 | * @returns A highly optimized function that returns whether an index matches the nth-check.
|
---|
| 7 | * @example
|
---|
| 8 | *
|
---|
| 9 | * ```js
|
---|
| 10 | * const check = nthCheck.compile([2, 3]);
|
---|
| 11 | *
|
---|
| 12 | * check(0); // `false`
|
---|
| 13 | * check(1); // `false`
|
---|
| 14 | * check(2); // `true`
|
---|
| 15 | * check(3); // `false`
|
---|
| 16 | * check(4); // `true`
|
---|
| 17 | * check(5); // `false`
|
---|
| 18 | * check(6); // `true`
|
---|
| 19 | * ```
|
---|
| 20 | */
|
---|
| 21 | export declare function compile(parsed: [a: number, b: number]): (index: number) => boolean;
|
---|
| 22 | /**
|
---|
| 23 | * Returns a function that produces a monotonously increasing sequence of indices.
|
---|
| 24 | *
|
---|
| 25 | * If the sequence has an end, the returned function will return `null` after
|
---|
| 26 | * the last index in the sequence.
|
---|
| 27 | *
|
---|
| 28 | * @param parsed A tuple [a, b], as returned by `parse`.
|
---|
| 29 | * @returns A function that produces a sequence of indices.
|
---|
| 30 | * @example <caption>Always increasing (2n+3)</caption>
|
---|
| 31 | *
|
---|
| 32 | * ```js
|
---|
| 33 | * const gen = nthCheck.generate([2, 3])
|
---|
| 34 | *
|
---|
| 35 | * gen() // `1`
|
---|
| 36 | * gen() // `3`
|
---|
| 37 | * gen() // `5`
|
---|
| 38 | * gen() // `8`
|
---|
| 39 | * gen() // `11`
|
---|
| 40 | * ```
|
---|
| 41 | *
|
---|
| 42 | * @example <caption>With end value (-2n+10)</caption>
|
---|
| 43 | *
|
---|
| 44 | * ```js
|
---|
| 45 | *
|
---|
| 46 | * const gen = nthCheck.generate([-2, 5]);
|
---|
| 47 | *
|
---|
| 48 | * gen() // 0
|
---|
| 49 | * gen() // 2
|
---|
| 50 | * gen() // 4
|
---|
| 51 | * gen() // null
|
---|
| 52 | * ```
|
---|
| 53 | */
|
---|
| 54 | export declare function generate(parsed: [a: number, b: number]): () => number | null;
|
---|
| 55 | //# sourceMappingURL=compile.d.ts.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.