source: trip-planner-front/node_modules/nth-check/lib/index.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.compile = exports.parse = void 0;
4var parse_1 = require("./parse");
5Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
6var compile_1 = require("./compile");
7Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
8/**
9 * Parses and compiles a formula to a highly optimized function.
10 * Combination of `parse` and `compile`.
11 *
12 * If the formula doesn't match any elements,
13 * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
14 * Otherwise, a function accepting an _index_ is returned, which returns
15 * whether or not the passed _index_ matches the formula.
16 *
17 * Note: The nth-rule starts counting at `1`, the returned function at `0`.
18 *
19 * @param formula The formula to compile.
20 * @example
21 * const check = nthCheck("2n+3");
22 *
23 * check(0); // `false`
24 * check(1); // `false`
25 * check(2); // `true`
26 * check(3); // `false`
27 * check(4); // `true`
28 * check(5); // `false`
29 * check(6); // `true`
30 */
31function nthCheck(formula) {
32 return (0, compile_1.compile)((0, parse_1.parse)(formula));
33}
34exports.default = nthCheck;
Note: See TracBrowser for help on using the repository browser.