open-index/open-npm huggingface dataset:
npm package: @jimengio/serve-json
Description: Serve JSON ----
Author: jiyinyiyong
Latest version: 0.0.6


Serve JSON
----

### Usage

![](https://img.shields.io/npm/v/@jimengio/serve-json.svg?style=flat-square)

```bash
yarn global add @jimengio/serve-json
serve-json config.edn
```

Example of `config.edn`:

```cirru
{
  :port 7800
  :fallback-host nil
  :routes [
    {
      :path "home"
      :get {:type :file, :file "home.json"}
    }
    {
      :path "plants/:plant-id"
      :get {:type :file, :file "plant-default.json"}
      :post {:type :file, :file "ok.json"}
      :next [
        {
          :path "overview"
          :get {:type :file, :file "overview.json"}
        }
        {
          :path "materials/:material-id"
          :get {:type :file, :file "materials.json"}
          :next [
            {
              :path "events"
              :get {:type :file, :file "events.json"}
              :delete {:code 202, :type :file, :file "ok.json"}
            }
          ]
        }
      ]
    }
  ]
}
```

Besides EDN, JSON, [CSON](https://github.com/bevry/cson), YAML and [Cirru EDN](https://github.com/Cirru/cirru-edn) are also supported([Comparison of data formats supported #5](https://github.com/jimengio/serve-json/issues/5)):

```bash
serve-json config.json

# also
serve-json config.cirru

# also
serve-json config.cson

# also
serve-json config.yaml
```

#### `:fallback-host`

When `:fallback-host` is specified, it will be used as a default proxy target when no config path is matched.

### License

MIT
npm package: @jimengio/shared-utils
Description: Misc utitilies across sites
Author: JIMENG
Latest version: 0.1.5
Deprecated: shared-utils was a general package, deprecated for long.

## Shared Utils

> 业务项目当中剥离出来的通用的函数, 用来跨项目复用. 兼容老项目运行为主(样式部分建议直接用 [flex-styles](https://github.com/jimengio/flex-styles)).

### Usage

![](https://img.shields.io/npm/v/@jimengio/shared-utils.svg?style=flat-square)

```bash
yarn add @jimengio/shared-utils
```

Immer helper functions:

```js
immerHelpers.immerState;
immerHelpers.mergeState;
```

Detecting functions:

```js
interpose;
some;
isFunction;
isNil;
hasItems;
isListEmpty;
isAnEmptyList;
immerMerge;
```

String functions:

```js
fuzzyFoundText;
foundText;
```

> Layout styles:

> Flexbox related styles has been moved to the package [flex-styles](https://github.com/jimengio/flex-styles).

### License

MIT
npm package: @jimengio/states-cursor
Description: > An alternative for Respo cursor.
Latest version: 0.0.1-a1

## States Cursor

> An alternative for Respo cursor.

States in React components are reset during Webpack how code replacement. Respo cursor proposed a solution by maintaining a global states tree and using manual states passing to hold states. This library tries to offer a alternative library for use case in React.

### Usages

![](https://img.shields.io/npm/v/@jimengio/states-cursor.svg)

```bash
yarn add @jimengio/states-cursor
```

```ts
import { rootStatesCursor } from "@jimengio/states-cursor";

// at root component
let rootCursor = rootStatesCursor();

// at child component
let cursorPageA = rootCursor.extends("a");

// another child page
let cursorPageB = rootCursor.extends("b");

// list of children
let childCursor = cursorPageA.extends(`child-${idx}`);
```

Manage states:

```ts
cursor.init({ a: 1 });

cursor.state; // gets {a: 1}

cursor.updateState((draft) => {
  draft.a = draft.a + 1;
});
```

listen to changes and rerender page:

```ts
import { addStatesListener, removeStatesListener } from "@jimengio/states-cursor";

addStatesListener(() => {
  // console.log("requests rerender from states");
  renderApp();
});
```

Reset states on unmount:

```ts
useEffect(() => {
  return () => {
    props.cursor.forceUmountTree();
  };
}, []);
```

### Workflow

https://github.com/jimengio/ts-workflow

### License

MIT
npm package: @jimengio/swagger-mon
Description: ClojureScript workflow using Calcit Editor
Author: jiyinyiyong
Latest version: 0.0.4


Swagger Mon
----

> generate mock data from swagger schema


Site http://fe.jimu.io/swagger-mon/

### Usages

[![Clojars Project](https://img.shields.io/clojars/v/jimengio/swagger-mon.svg)](https://clojars.org/jimengio/swagger-mon)

```edn
[jimengio/swagger-mon "0.0.3"]
```

```clojure
(swagger-mon.core/gen-data schema-obj) ; returns json object
```

For swagger definition:

```json
{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"id":{"type":"string"},"categoryId":{"type":"string"},"name":{"type":"string"},"varname":{"type":"string"},"type":{"type":"string"},"unit":{"type":"string"},"readonly":{"type":"boolean"},"reportType":{"type":"string"},"intervalMsec":{"type":"number"},"description":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}}
```

Generate data with random values:

```json
{
  "readonly": false,
  "updatedAt": "2020-03-04T04:25:36.505Z",
  "reportType": "深圳",
  "createdAt": "2020-03-04T04:25:36.505Z",
  "id": "PN8R1ToO",
  "name": "菏泽",
  "type": "Quanzhou 黄山 嘉兴",
  "varname": "Yinchuan",
  "unit": "Hainan 舟山 保山",
  "intervalMsec": 69,
  "description": "Yichun 张家界 石家庄 Neijiang",
  "categoryId": "ks6MVtWng"
}
```

Mock strings are based on https://github.com/brightgems/china_city_dataset .

### CLI

![swagger-mon on npm](https://img.shields.io/npm/v/@jimengio/swagger-mon.svg)

```bash
yarn global add @jimengio/swagger-mon
```

Then run command `swagger-api.json`:

```bash
# prepare a ./swagger-api.json first!

swagger-mon # read...

# default HTTP port
PORT=7801 swagger-mon
```

### Workflow

Workflow https://github.com/mvc-works/calcit-workflow

### License

MIT
npm package: @jimengio/use-worker
Description: useWorker() - Web worker using React hook
Author: alewin
Latest version: 3.3.0

# use-worker

Use web workers with react hook

[![npm](https://img.shields.io/npm/v/@jimengio/use-worker.svg)](https://www.npmjs.com/package/@jimengio/use-worker)

Fork: https://github.com/alewin/useWorker

## Usage

```shell
yarn add @jimengio/use-worker
```

```jsx
import React from "react";
import { useWorker } from "@jimengio/use-worker";

const numbers = [...Array(5000000)].map((e) => ~~(Math.random() * 1000000));
const sortNumbers = (nums) => nums.sort();

const Example = () => {
  const { callback: sortWorker } = useWorker(sortNumbers);

  const runSort = async () => {
    const result = await sortWorker(numbers); // non-blocking UI
    console.log("End.");
  };

  return (
    <button type="button" onClick={runSort}>
      Run Sort
    </button>
  );
};
```

## Dev

```shell
# build package
yarn build

# tests
yarn test

# lint
yarn eslint
```

## License

[MIT](./LICENSE)