Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
fc3c16c
commit 21ab584
Showing
21 changed files
with
1,375 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,4 +88,5 @@ ignore: | |
- src/types/ | ||
|
||
profiling: | ||
critical_files_paths: [] | ||
critical_files_paths: | ||
- src/lexer.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @file Fixtures - dblLinear | ||
* @module fixtures/dblLinear | ||
* @see https://codewars.com/kata/5672682212c8ecf83e000050 | ||
*/ | ||
|
||
/** | ||
* Consider a sequence `u` where `u` is defined as follows: | ||
* | ||
* 1. The number `u(0) = 1` is the first one in `u` | ||
* 2. For each `x` in `u`, `y = 2x + 1` and `z = 3x + 1` must be in `u` too | ||
* 3. There are no other numbers in `u` | ||
* | ||
* Given an index, `n`, the function returns the element at `u(n)`. | ||
* | ||
* @async | ||
* | ||
* @example | ||
* await dblLinear(0) // 1 | ||
* @example | ||
* await dblLinear(10) // 22 | ||
* @example | ||
* await dblLinear(100) // 447 | ||
* @example | ||
* await dblLinear(7687) // 111718 | ||
* | ||
* @param {number} n - Index of element to get | ||
* @return {Promise<number>} Element at `u(n)` | ||
*/ | ||
async function dblLinear(n: number): Promise<number> { | ||
/** @const {number[]} u - Sequence */ | ||
const u: number[] = [1] | ||
|
||
/** @var {number} j - Index of x in {@linkcode u} used to calculate y */ | ||
let j: number = 0 | ||
|
||
/** @var {number} k - Index of x in {@linkcode u} used to calculate z */ | ||
let k: number = 0 | ||
|
||
/* | ||
* build sequence up to index n (inclusive) | ||
*/ | ||
for (let i = 1; i <= n; i++) { | ||
/** @const {number} y - `y` */ | ||
const y: number = 2 * u[j]! + 1 | ||
|
||
/** @const {number} z - `z` */ | ||
const z: number = 3 * u[k]! + 1 | ||
|
||
/* set sequence value to smallest value in [y, z] */ | ||
u[i] = Math.min(y, z) | ||
|
||
// increase of index of x used to calculate y by 1 | ||
if (u[i] === y) j++ | ||
|
||
// increase of index of x used to calculate z by 1 | ||
if (u[i] === z) k++ | ||
} | ||
|
||
return u[n]! | ||
} | ||
|
||
export default dblLinear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @file Fixtures - detectSyntax | ||
* @module fixtures/detectSyntax | ||
*/ | ||
|
||
import { hasCJSSyntax, hasESMSyntax } from '@flex-development/mlly' | ||
|
||
/** | ||
* Detects if `code` contains CommonJS syntax, ESM syntax, or a mixture of both. | ||
* | ||
* Ignores matches in comments. | ||
* | ||
* @see {@linkcode hasCJSSyntax} | ||
* @see {@linkcode hasESMSyntax} | ||
* | ||
* @example | ||
* import { detectSyntax } from '@flex-development/mlly' | ||
* | ||
* console.debug(detectSyntax('export default {}')) | ||
* | ||
* @param {string} code - Code to evaluate | ||
* @return {{ cjs: boolean; esm: boolean; mixed: boolean }} Detection result | ||
*/ | ||
const detectSyntax = ( | ||
code: string | ||
): { cjs: boolean; esm: boolean; mixed: boolean } => { | ||
/** | ||
* CommonJS syntax check. | ||
* | ||
* @const {boolean} cjs | ||
*/ | ||
const cjs: boolean = hasCJSSyntax(code) | ||
|
||
/** | ||
* ESM syntax check. | ||
* | ||
* @const {boolean} esm | ||
*/ | ||
const esm: boolean = hasESMSyntax(code) | ||
|
||
return { cjs, esm, mixed: cjs && esm } | ||
} | ||
|
||
export default detectSyntax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.