open-index/open-npm huggingface dataset:
npm package: @sevenoutman/date-z
Description: Date-time API with timezone in mind
Latest version: 0.1.0

# date-z

[![npm version](https://badgen.net/npm/v/@sevenoutman/date-z)](https://npm.im/@sevenoutman/date-z) [![npm downloads](https://badgen.net/npm/dm/@sevenoutman/date-z)](https://npm.im/@sevenoutman/date-z)
[![codecov](https://codecov.io/gh/SevenOutman/date-z/graph/badge.svg?token=5xJVmpIodz)](https://codecov.io/gh/SevenOutman/date-z)

Date-time API with timezone in mind.

## Install

```bash
npm i @sevenoutman/date-z
```

## Usage

> 🚧 This library is still in early development. API could change. Use with caution.

```js
import { ZonedDateTime } from "@sevenoutman/date-z"

const zonedDate = new ZonedDateTime(
  1409529600000, // "2014-09-01T00:00:00.000Z"
  "Europe/Dublin", // UTC+1
)

zonedDate.getHours() // 1
zonedDate.toString() // "2014-09-01T01:00:00.000+01:00[Europe/Dublin]"
```

## API

### CalendarDate

A calendar date is a date representation without time and timezone information.
It does **not** have an equivalent timestamp, because the same date could be represented by different timestamps in different timezones.

```js
import { CalendarDate } from "@sevenoutman/date-z"

const date = new CalendarDate(2014, 8, 1) // 2014-09-01
```

Calendar dates themselves can be compared with `CalendarDate.difference()` function.

```js
import { CalendarDate } from "@sevenoutman/date-z"

const date1 = new CalendarDate(2014, 8, 1) // 2014-09-01
const date2 = new CalendarDate(2014, 8, 2) // 2014-09-02

CalendarDate.difference(date1, date2) // -1
```

### Instant

A instant is a timestamp representation without timezone information.
It does **not** have an equivalent calendar date, because the same timestamp could be represented by different dates in different timezones.

```js
import { Instant } from "@sevenoutman/date-z"

const time = new Instant(1409526720000) // "2014-09-01T00:00:00.000Z"
```

To convert between a calendar date (or date-time) and timestamp requires specifying the context.

```js
import { Instant, CalendarDate } from "@sevenoutman/date-z"

const time = new Instant(1409526720000) // "2014-09-01T00:00:00.000+08:00"

time.toCalendarDate("Europe/Dublin") // { year: 2014, month: 7, date: 31 }
time.toCalendarDate("Asia/Shanghai") // { year: 2014, month: 8, date: 1 }
```

## Philosophy

The philosophy behind this library is similar to what's behind [Temporal proposal](https://github.com/tc39/proposal-temporal) -
A date-time representation does not have an equivalent timestamp, unless timezone is specified in the context, and vice versa.

## License

MIT &copy; [Doma](https://github.com/SevenOutman)
npm package: @sevenoutman/react-promised
Description: > React component for rendering children according to a promise
Author: Doma
Latest version: 1.0.0

# react-promised

> React component for rendering children according to a promise

    yarn add @sevenoutman/react-promised

## Usage

```jsx
import Promised from '@sevenoutman/react-promised';

function App() {

    const [fetchTodoPromise, setFetchTodoPromise] = useState();

    useEffect(() => {
        setFetchTodoPromise(requestTodos());
    }, []);

    return (
        <Promised promise={fetchTodoPromise} defaultPending>
            {({ pending, rejected: error, resolved: todos }) => {
                
                if (pending) return <Loading />;
                if (error) return <ErrorMessage error={error} />

                return (
                    <ul>
                      {todos.map(todo => (
                          <li key={todo.id}>{todo.content}</li>
                      ))}
                    </ul>
                );
            }}
        </Promised>
    );
}
```

## Props

```typescript
interface RenderProp<T, E> {
    (params: {
        pending?: boolean;
        rejected?: E;
        resolved?: T;
    }): React.ReactNode;
}

interface PromisedProps<TResult = any, TError extends Error = Error> {
    /**
     * The promise to watch
     */
    promise: Promise<TResult>;
    /**
     * A function that receives a { pending, rejected, resolved } object as parameter and returns ReactNode to render.
     */
    children: RenderProp<TResult, TError | any>;
    /**
     * Whether to set pending to true if `promise` is falsy, default to false.
     */
    defaultPending?: boolean;
    /**
     * Whether to abandon promise upon component unmount, default to true.
     * Useful to avoid updating states in unmounted components.
     */
    abandonOnUnmount?: boolean;
    /**
     * Callback when promise is resolved.
     * Will be affected by `abandonOnUnmount`.
     */
    onResolve?: (resolved: TResult) => void;
    /**
     * Callback when promise is rejected.
     * Will be affected by `abandonOnUnmount`.
     */
    onReject?: (rejected: TError | any) => void;
}
```
npm package: @sevenoutman/use-abandon-on-unmount
Description: > React Hook for abandoning promises upon component unmounting
Author: Doma
Latest version: 1.0.1

# useAbandonOnUnmount

> React Hook for abandoning promises upon component unmounting

    yarn add @sevenoutman/use-abandon-on-unmount

 ## Usage

 ```javascript
 import useAbandonOnUnmount from '@sevenoutman/use-abandon-on-unmount';
 
 function App() {

     const [data, setData] = useState();

     const abandonOnUnmount = useAbandonOnUnmount();

     const fetchData = useCallback(async () => {
         const result = await abandonOnUnmount(requestData());
         setData(result); // Will not excute after this component unmounts
     }, [setData]);

     return (
        // ...
     );
 }
 ```

 ## Why?

Get you rid of this:

     Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.
npm package: @sevenoutman/use-auto-increment
Description: > React Hook for auto incrementing value
Author: Doma
Latest version: 1.0.0
Deprecated: Use @sevenoutman/use-increment instead.

# use-auto-increment

> React Hook for auto incrementing value

    yarn add @sevenoutman/use-auto-increment

## Usage

```javascript
import useAutoIncrement from '@sevenoutman/use-auto-increment';

function App() {
    
    const [clickCount, increment] = useAutoIncrement(0);
    
    return (
        <Button onClick={increment}>
            You've clicked {clickCount} times.
        </Button>
    );
}
```

## API

### `useAutoIncrement(initialValue?: number, step?: number): [value, increment]`

Default hook signature, returns a array representing `[value, increment]`.

- `initialValue`: Initial value for `value`, defaults to 1.
- `step`: Increment step, defaults to 1.


### `increment(): void`

Increment `value` by `step`.

### `increment.by(amount: number): void`

When you want to increment your value by a different amount from `step`, use `increment.by(amount)`.
npm package: @sevenoutman/use-increment
Description: > React Hook for auto incrementing value
Author: Doma
Latest version: 1.0.0

# use-auto-increment

> React Hook for auto incrementing value

    yarn add @sevenoutman/use-auto-increment

## Usage

```javascript
import useAutoIncrement from '@sevenoutman/use-auto-increment';

function App() {
    
    const [clickCount, increment] = useAutoIncrement(0);
    
    return (
        <Button onClick={increment}>
            You've clicked {clickCount} times.
        </Button>
    );
}
```

## API

### `useAutoIncrement(initialValue?: number, step?: number): [value, increment]`

Default hook signature, returns a array representing `[value, increment]`.

- `initialValue`: Initial value for `value`, defaults to 1.
- `step`: Increment step, defaults to 1.


### `increment(): void`

Increment `value` by `step`.

### `increment.by(amount: number): void`

When you want to increment your value by a different amount from `step`, use `increment.by(amount)`.
npm package: @sevenqi/nodechannel
Description: nodejs channel
Author: SevenQi
Latest version: 1.1.6

# Supported Protocols

  |Protocol Name| Supported |
  |  ----       | :----: | 
  |  TcpSocket  | ☑    |
  |  UdpSocket  | ☑    |
  |  Hid        | ☑    |
  |  SerialPort | ☑    |

---
# Used libs
[node-serialport](https://github.com/serialport/node-serialport)
[node-hid](https://github.com/node-hid/node-hid)
[uuid](https://github.com/uuidjs/uuid)
[ws](https://github.com/websockets/ws)

---
# GetStarted
## Install
```shell
npm install @sevenqi/nodechannel
```

---
## Client Example 

### WebSocket 

```typescript
const sessionManager = new SessionManager();

const sessionId = sessionManager.add({
    channelType: ChannelType.WebSocket,
    channelOptions: {
        options: { address: "ws://0.0.0.0:8888" },
        filter: StringFilter
    }
})

sessionManager.onData(sessionId, (message: any) => {
    console.log("消息:", message)
})

const isConnected = await sessionManager.connect(sessionId);
if (isConnected)
    SessionManager.send(sessionId, Buffer.from("hello world"))
```