Skip to content

Commit

Permalink
refactor: rename utils to std
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanga-Ganapathy committed Mar 25, 2024
1 parent ff45390 commit 5917838
Show file tree
Hide file tree
Showing 289 changed files with 413 additions and 618 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

<div align="center">

# Utils
# JavaScript Standard Library

[![Build](https://github.com/open-tech-foundation/js-utils/actions/workflows/build.yml/badge.svg)](https://github.com/open-tech-foundation/js-utils/actions/workflows/build.yml)

</div>

> A collection of JavaScript utility functions.
> An Extensive JavaScript Standard Library.
<div align="center">

Expand All @@ -29,19 +29,19 @@
## Installation

```sh
npm install @opentf/utils
npm install @opentf/std
```

```sh
yarn add @opentf/utils
yarn add @opentf/std
```

```sh
pnpm add @opentf/utils
pnpm add @opentf/std
```

```sh
bun add @opentf/utils
bun add @opentf/std
```

## Usage
Expand All @@ -55,7 +55,7 @@ import {
isEql,
isEqlArr,
sleep,
} from "@opentf/utils";
} from "@opentf/std";

isNum(NaN); //=> false

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/components/PlaygroundREPL.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const NodeREPL = dynamic(
{ ssr: false }
);

const code = `const { range, diff, camelCase } = require('@opentf/utils');
const code = `const { range, diff, camelCase } = require('@opentf/std');
log(diff(
['apple', 'mango', 'orange'],
Expand All @@ -31,7 +31,7 @@ export default function PlaygroundREPL() {
<NodeREPL
code={code}
setupCode={setupCode}
deps={["@opentf/utils", "lodash", "ramda"]}
deps={["@opentf/std", "lodash", "ramda"]}
layout="SPLIT_PANEL"
editor={{
darkMode: resolvedTheme === "dark",
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/REPL.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function REPL({ code = "", layout = "DEFAULT" }) {
<NodeREPL
code={code}
setupCode={setupCode}
deps={["@opentf/utils", "lodash", 'ramda']}
deps={["@opentf/std", "lodash", 'ramda']}
editor={{
darkMode: resolvedTheme === "dark",
header: false,
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/arrIns.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Immutable: This does not mutate the given array.
## Syntax

```ts copy
import { arrIns } from '@opentf/utils';
import { arrIns } from '@opentf/std';

arrIns<T>(
arr: T[] = [],
Expand Down Expand Up @@ -52,7 +52,7 @@ arrIns([1, 2, 3], 0, ...[5, 6]) //=> [5, 6, 1, 2, 3]

## Try

<REPL code={`const { arrIns } = require('@opentf/utils');
<REPL code={`const { arrIns } = require('@opentf/std');
arrIns([1, 2, 3], 1, 5);
`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/arrReplace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Immutable: This does not mutate the given array.
## Syntax

```ts copy
import { arrReplace } from '@opentf/utils';
import { arrReplace } from '@opentf/std';

arrReplace<T>(
arr: T[] = [],
Expand Down Expand Up @@ -39,7 +39,7 @@ arrReplace([1, 2, 3], 5, 'c', 'd') // => [1, 2, 3, 'c', 'd']

## Try

<REPL code={`const { arrReplace } = require('@opentf/utils');
<REPL code={`const { arrReplace } = require('@opentf/std');
arrReplace([1, 2, 3], 1, 'Two');
`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/arrRm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Immutable: This does not mutate the given array.
## Syntax

```ts copy
import { arrRm } from '@opentf/utils';
import { arrRm } from '@opentf/std';

arrRm<T>(
arr: T[] = [],
Expand Down Expand Up @@ -46,7 +46,7 @@ arrRm(myFish, 2, Infinity) // => ['angel', 'clown']);

## Try

<REPL code={`const { arrRm } = require('@opentf/utils');
<REPL code={`const { arrRm } = require('@opentf/std');
arrRm([1, 2, 3, 4, 5], 2);
`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/bounds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If duplicate values are present in the array, then the first match will be retur
## Syntax

```ts copy
import { bounds } from '@opentf/utils';
import { bounds } from '@opentf/std';

bounds<T>(
arr: T[] = [],
Expand Down Expand Up @@ -58,7 +58,7 @@ bounds(arr, (o) => o.age)

## Try

<REPL code={`const { bounds } = require('@opentf/utils');
<REPL code={`const { bounds } = require('@opentf/std');
bounds([1, 2, 3, 4, 5]);
`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/chunk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import REPL from "../../components/REPL";
## Syntax

```ts copy
import { chunk } from '@opentf/utils';
import { chunk } from '@opentf/std';

chunk(arr: unknown[], size = 1): unknown[];
```
Expand All @@ -27,6 +27,6 @@ chunk([1, 2, 3], 4) //=> [[1, 2, 3]]

## Try

<REPL code={`const { chunk } = require('@opentf/utils');
<REPL code={`const { chunk } = require('@opentf/std');
chunk([1, 2, 3, 4, 5], 2);`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/compact.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Immutable: This does not mutate the given array.
## Syntax

```ts copy
import { compact } from '@opentf/utils';
import { compact } from '@opentf/std';

compact<T>(arr: T[] = []): Partial<T[]>;
```
Expand All @@ -37,6 +37,6 @@ compact(['apple', '', 'Mango']) //=>['apple', 'Mango']);

## Try

<REPL code={`const { compact } = require('@opentf/utils');
<REPL code={`const { compact } = require('@opentf/std');
compact([1, null, 2, 0, 3]);`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/countBy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import REPL from "../../components/REPL";
## Syntax

```ts
import { countBy } from '@opentf/utils';
import { countBy } from '@opentf/std';

countBy<T>(
arr: T[] = [],
Expand Down Expand Up @@ -53,7 +53,7 @@ countBy(letters, (l) => l.toLowerCase())

## Try

<REPL code={`const { countBy } = require('@opentf/utils');
<REPL code={`const { countBy } = require('@opentf/std');
const letters = ['a', 'b', 'A', 'a', 'B', 'c'];
countBy(letters, (l) => l.toLowerCase());
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/diff.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It uses [isEql](/Assert/isEql) for deep comparison of values.
## Syntax

```ts copy
import { diff } from '@opentf/utils';
import { diff } from '@opentf/std';

diff(
collections: unknown[][] = [],
Expand All @@ -48,7 +48,7 @@ diff([[{ a: 1 }, {a: 3}], [{ a: 1 }, { a: 2 }]]); //=> [{a: 3}]

## Try

<REPL code={`const { diff } = require('@opentf/utils');
<REPL code={`const { diff } = require('@opentf/std');
const odds = [1, 3, 5, 7, 9];
const squares = [1, 4, 9];
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/groupBy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The key can be a string or a callback function that must return a string.
## Syntax

```ts
import { groupBy } from '@opentf/utils';
import { groupBy } from '@opentf/std';

groupBy(arr: unknown[], key: string | x => string);
```
Expand Down Expand Up @@ -51,7 +51,7 @@ groupBy(["one", "two", "three"], "length"))

## Try

<REPL code={`const { groupBy } = require('@opentf/utils');
<REPL code={`const { groupBy } = require('@opentf/std');
const products = [
{ name: "apples", category: "fruits" },
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/intersection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It uses [isEql](/Assert/isEql) for deep comparison of values.
## Syntax

```ts copy
import { intersection } from '@opentf/utils';
import { intersection } from '@opentf/std';

intersection(
collections: unknown[][] = [],
Expand Down Expand Up @@ -56,7 +56,7 @@ intersection(

## Try

<REPL code={`const { intersection } = require('@opentf/utils');
<REPL code={`const { intersection } = require('@opentf/std');
const setA = [1, 2];
const setB = [2, 3];
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/max.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If duplicate values are present in the array, then the first match will be retur
## Syntax

```ts copy
import { max } from '@opentf/utils';
import { max } from '@opentf/std';

max<T>(
arr: T[] = [],
Expand Down Expand Up @@ -56,7 +56,7 @@ max(arr, (o) => o.age))

## Try

<REPL code={`const { max } = require('@opentf/utils');
<REPL code={`const { max } = require('@opentf/std');
max([1, 2, 3, 4, 5]);
`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/min.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If duplicate values are present in the array, then the first match will be retur
## Syntax

```ts copy
import { min } from '@opentf/utils';
import { min } from '@opentf/std';

min<T>(
arr: T[] = [],
Expand Down Expand Up @@ -60,7 +60,7 @@ min(arr, (f) => f.age)

## Try

<REPL code={`const { min } = require('@opentf/utils');
<REPL code={`const { min } = require('@opentf/std');
min([1, 2, -3, 4, 5]);
`} />
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/move.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ move(arr: T[], from: number, to: number): T[];
## Usage

```ts
import { move } from "@opentf/utils";
import { move } from "@opentf/std";

move([], 0, 1);
```
Expand All @@ -33,6 +33,6 @@ move([1, 2, 3], 5, 0); //=> [1, 2, 3]

## Try

<REPL code={`const { move } = require('@opentf/utils');
<REPL code={`const { move } = require('@opentf/std');
move([1, 2, 3], 0, 2);`} />
8 changes: 4 additions & 4 deletions apps/docs/pages/Array/range.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ The `step` value can be auto infered based on the `start` & `end` values.
</Callout>

<Callout type="info">
The `third` argument can be either a `step` value or `options` object.
The `third` argument can be either a `step` value or an `options` object.
</Callout>

## Usage

```ts
import { range } from '@opentf/utils';
import { range } from '@opentf/std';

range(start, stop);
range(start, end);
```

## Examples
Expand Down Expand Up @@ -63,7 +63,7 @@ range(10, 12, { step: 0.5 }) //=> [10, 10.5, 11, 11.5]

## Try

<REPL code={`const { range } = require('@opentf/utils');
<REPL code={`const { range } = require('@opentf/std');
log(range(1, 5));
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/sort.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The order param can be either `'asc'` or `'desc'`.
## Usage

```ts
import { sort } from "@opentf/utils";
import { sort } from "@opentf/std";

sort([...]);
```
Expand All @@ -51,7 +51,7 @@ sort(['x', 'z', 'y'], 'desc') //=> ['z', 'y', 'x']

## Try

<REPL code={`const { sort } = require('@opentf/utils');
<REPL code={`const { sort } = require('@opentf/std');
const months = ["Mar", "Jan", "Feb", "Dec"];
const sortedMonths = sort(months);
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/sortBy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The `key` in the tuple array must one of object first level props.
## Usage

```ts
import { sortBy } from "@opentf/utils";
import { sortBy } from "@opentf/std";

sortBy([{...}], ['key', 'asc'], [o => o.prop, 'desc']);
```
Expand Down Expand Up @@ -65,7 +65,7 @@ sortBy(fruits, [o => o.amount, 'desc'], [o => o.name, 'asc']);

## Try

<REPL code={`const { sortBy } = require('@opentf/utils');
<REPL code={`const { sortBy } = require('@opentf/std');
const fruits = [
{ name: 'banana', amount: 2 },
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/pages/Array/symDiff.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It uses [isEql](/Assert/isEql) for deep comparison of values.
## Syntax

```ts copy
import { symDiff } from '@opentf/utils';
import { symDiff } from '@opentf/std';

symDiff(
collections: unknown[][] = [],
Expand Down Expand Up @@ -51,7 +51,7 @@ symDiff([bucket1, bucket2], (v) => v.toLowerCase())

## Try

<REPL code={`const { symDiff } = require('@opentf/utils');
<REPL code={`const { symDiff } = require('@opentf/std');
const bucket1 = ['Fruits', 'Vegs', 'Eggs', 'Cookies', 'Nuts'];
const bucket2 = ['fruits', 'Snacks', 'cookies'];
Expand Down

0 comments on commit 5917838

Please sign in to comment.