open-index/open-npm huggingface dataset:
npm package: @hanshi/array-typeclass
Description: A package providing type-class implentations such as monad and traversable to the native javascript array.
Author: Guo, Yunsheng
Latest version: 0.0.6

# `@hanshi/array-typeclass`

```typescript
import * as AT from '@hanshi/array-typeclass';
import { _ } from '@hanshi/prelude';

const add = (n: number) => n + 1;

console.log('fmap add [1,2,3,4,5] = ', AT.fmap(add, [1, 2, 3, 4, 5]));

const linear = (a: number, x: number, b: number) => a * x + b;

console.log(
    'linear <$> [-1, 0, 1, 2] <*> [-2, -1, 0, 1, 2, 3] <*> [-1, 0, 1] = ',
    AT.tie(
        AT.tie(AT.fmap(linear, [-1, 0, 1, 2]), [-2, -1, 0, 1, 2, 3]),
        [-1, 0, 1]
    )
);

const liftedLinear = AT.lift(linear);

console.log(
    'liftedLinear [-1, 0, 1, 2] [-2, -1, 0, 1, 2, 3] [-1, 0, 1] = ',
    liftedLinear([-1, 0, 1, 2], [-2, -1, 0, 1, 2, 3], [-1, 0, 1])
);

const limitedLinear = (a: number, b: number) =>
    AT.tie(AT.fmap(_(linear, a), [-2, -1, 0, 1, 2, 3, 4, 5]), AT.pure(b));

for (const i of [-1, 0, 1])
    for (const j of [-2, 0, 3])
        console.log(`limitedLinear(${i}, ${j})`, limitedLinear(i, j));

console.log(
    'limitedLinear =<< [-1,0,1] <<= [-2, 0 ,3 ] = ',
    AT.warp([-2, 3], AT.warp([-1, 1], limitedLinear))
);

console.log(
    'limitedLinear =<< [-1,0,1] <<= [-2, 0 ,3 ] = ',
    AT.warp([-1, 1], limitedLinear)(5)
);
```
npm package: @hanshi/maybe
Description: A package providing an implementation of maybe.
Author: Guo, Yunsheng
Latest version: 0.1.9

# `maybe`

```typescript
import { Just, Maybe, Nothing, maybe, nothing } from '@hanshi/maybe';
import { FirstParameter, Unary, id } from '@hanshi/prelude';

function isEmpty<T>(a: T): boolean {
    switch (typeof a) {
        case 'undefined':
        case 'function':
        case 'symbol':
            return true;
        case 'string':
            return a.trim().length === 0;
        case 'number':
            return Number.isNaN(a);
        case 'object':
            if (a === null) return true;
            if (Array.isArray(a)) return a.every(isEmpty);
            return Object.entries(a).every((kv) => kv.some(isEmpty));
        default:
            return true;
    }
}

function get<F extends Unary>(
    f: F,
    a: FirstParameter<F>
): Maybe<ReturnType<F>> {
    try {
        const v = f(a);
        return isEmpty(v) ? nothing : Just.of(v);
    } catch (e) {
        console.debug(e);
        return nothing;
    }
}

const k = {
    a: { b: 2 },
    c: 'ok',
    empty: { a: '  ', b: NaN, c: [' ', NaN, {}], d: {} }
};

console.log(get((o) => o.d.a, k));

console.log(get((o) => o.a.b, k));

console.log(get((o) => o.empty, k));

console.log(
    maybe(
        'ok',
        id,
        get((o) => o.empty, k)
    )
);
```
npm package: @hanshi/prelude
Description: A package providing a cluster of basic functions for hanshi.
Author: Guo, Yunsheng
Latest version: 0.2.4

# `prelude`

```typescript
import { _, curry } from '@hanshi/prelude';

const add = (a: number, b: number) => a + b;

const add2With = _(add, 2);

console.log(add(2, 3) === add2With(3));

const linear = (a: number, b: number, x: number) => a * x + b;

const curriedLinear = curry(linear);

const [a, b, c] = [...Array(3).keys()].map(() => Math.random());

console.log(linear(a, b, c) === curriedLinear(a)(b)(c));
```
npm package: @hanshi/promise-typeclass
Description: A package providing type-class implentations such as monad and traversable to the native type promise.
Author: Guo, Yunsheng
Latest version: 0.1.9

# `promise-typeclass`

```Typescript
import {
    warp as warpPromise,
    fmap as fmapPromise,
    lift as liftPromise
} from '@hanshi/promise-typeclass';

const waitedValue = <T>(v: T, t: number): Promise<T> =>
    new Promise((resolve) => setTimeout(() => resolve(v), t));

const terminalWithPromise = (a: number): Promise<number> =>
    new Promise((resolve) => setTimeout(() => resolve(a + 5), 500));

const waited1sNumber10 = warpPromise(waitedValue(5, 500), terminalWithPromise); // For any function that returns a promise, warp(or `>>=` in `haskell) can `partial apply` a promise as if it's normal(awaited), and **return as usual**.

function display<T>(n: T) {
    console.log('value', n);
}

fmapPromise(display, waited1sNumber10); // For any function(terminated with a promise or not), `fmap` can apply a promise instead of the normal(awaited), but **returns a Promise of the value as result**.

// The function `display` does not return anything, so technically it now returns a Promise<void>.

// The side effect of promises are also retained by `fmap`. For instance this `display` invocation will wait for 1 second in the scheduler.

const terminalWithPromise2 = (a: number, b: string): Promise<number> =>
    new Promise((resolve) => setTimeout(() => resolve(b.length + a), 2000));

const waited4sNumber20 = warpPromise(
    waitedValue(10, 1000),
    warpPromise(waitedValue('abcdefghji', 1000), terminalWithPromise2)
); // Due to the fact that `monad` has associativity, `warp` operation works in a reverse order from `partial application`.

fmapPromise(display, waited4sNumber20); // This `display` invocation will wait for 4 seconds in the scheduler, since all the side effects are retained.

const noneTerminal = (name: string, value: object): string =>
    name + JSON.stringify(value);

const liftedNoneTerminal = liftPromise(noneTerminal); // `Lift` takes a function and returns a version of it that all parameters and the return value are promises.

fmapPromise(
    display,
    liftedNoneTerminal(
        waitedValue('waited name', 1500),
        waitedValue({ sample: 1 }, 1500)
    )
); // This `display` invocation will wait for 3 seconds in the scheduler, since all the side effects are retained.
```
npm package: @hanshi/typeclass
Description: A package providing some common default typeclass methods implementations given minimum complete definition of said typeclass
Author: Guo, Yunsheng
Latest version: 0.1.4

# `@hanshi/typeclass`

```Typescript
import {
    FirstParameter,
    Functional,
    PartialApplied,
    Unary,
    cons,
    left,
    partial,
    proxied,
    right
} from '@hanshi/prelude';
import {
    defineLeftTie,
    defineLift,
    defineReplace,
    defineInsert,
    defineTie,
    defineTraverse
} from '../lib';

const fmap = <F extends Functional>(
    f: F,
    aa: FirstParameter<F>[]
): PartialApplied<F>[] => aa.map((a) => partial(f, a));

const v$ = <A, B>(a: A, bs: B[]): A[] => bs.map(() => a);

const replace2 = defineReplace(fmap) as <A, B>(a: A, ab: B[]) => A[];

const pure = <T>(a: T) => [a];

const tie = <F extends Functional>(af: F[], aa: FirstParameter<F>[]) =>
    aa.flatMap((a) => af.map((f) => partial(f, a)));

const lift = <F extends Functional>(f: F) =>
    proxied(
        (target, args) =>
            args
                .reduce(
                    (prev, as) =>
                        prev.length === 0
                            ? as.map((a) => [a])
                            : as.flatMap((a) => prev.map((p) => p.concat(a))),
                    []
                )
                .map((as) => target(...as)),
        f
    );
const lift2 = defineLift(fmap, tie);

const tie2 = defineTie(lift2);

const rightTie = <A, B>(as: A[], bs: B[]) =>
    bs.flatMap((b) => as.flatMap((a) => right(a, b)));

const insert2 = defineInsert(replace2, tie2);

const leftTie = <A, B>(as: A[], bs: B[]) =>
    bs.flatMap((b) => as.flatMap((a) => left(a, b)));

const leftTie2 = defineLeftTie(lift2);

const sequence = (() => {
    const sequence: Unary = (fa) => {
        if (fa.length === 0) return pure(fa);
        const [x, ...xs] = fa;
        return tie(fmap(cons, x), sequence(xs));
    };
    return sequence;
})();

const traverse = defineTraverse(fmap, sequence);
```
npm package: @hansnow/q-star
Description: q star ui for pc
Author: hansnow
Latest version: 0.1.3

# FakeWJX PC端组件库

### 使用方法

1. 在本项目目录内`npm install`
2. `npm run build`
3. `npm link`
4. 在其他项目目录内`npm link @hansnow/q-star`

### 如何发布

`npm publish --access public`


### 参考资料

1. [How to Write Your Own Reusable React Component Library](https://itnext.io/how-to-write-your-own-reusable-react-component-library-a57dc7c9a210)
2. [rinse-react](https://github.com/cwlsn/rinse-react)
npm package: @hansogj/find-js
Description: Returning an iterable array of the result of  querySelectorAll from root to selector 
Author: Hans Ole Gjerdrum
Latest version: 6.7.4

# find-js

Returns an iterable array of node-elements.

## Usage

### JS

```js
// either
const find = require("@hansogj/find-js").default;

//or
<script src="../node_modules/@hansogj/find-js/dist/index.js"></script>
const find = window.find.default;

----
console.log(find('h2', window.document.body));
```

### TS

```ts
import find from 'find-js';

console.log(find('h2', window.document.body));
```