open-index/open-npm huggingface dataset:
npm package: @neumatter/big-integer
Description: An extendable class representing JavaScript's bigint data type.
Author: Cal Young
Latest version: 1.0.0


# BigInteger
![plot](https://img.shields.io/npm/v/@neumatter/big-integer?style=for-the-badge&labelColor=black)
![plot](https://img.shields.io/npm/dt/@neumatter/big-integer?style=for-the-badge&labelColor=black)
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/big-integer
```

<br />

<a name="usage"></a>
## Usage


### static (class) `BigInteger.from`:

Args [`value: Uint8Array | Buffer | ByteView | BigIntegerJSON | BigInteger | string | number | boolean`]

Returns `BigInteger`

```js
import BigInteger from '@neumatter/big-integer'

const bigInteger = BigInteger.from('9249234234093460909559834421')

// use bigInteger
```
npm package: @neumatter/bvon
Description: Serialize data into buffer. Browser or NodeJS.
Author: Cal Young
Latest version: 1.0.2


# BVON
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

Serialize data into a buffer. Result size is smaller than BSON and JSON. Browser or NodeJS.

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/bvon
```

<br />

<a name="usage"></a>
## Usage


### static (class) `BVON.serialize`:

Args [`data: any`, `schema?: BVON.Schema`]

Returns `ByteView`

#### without schema:
```js
import BVON, { UOID } from '@neumatter/bvon'

const user = {
  id: new UOID('2LD32T9NBPMF3YDQYLVANMG22A2J'),
  name: {
    first: 'Mike',
    last: 'Williamson'
  },
  createdAt: new Date('2023-03-02T06:00:00.000Z'),
  modifiedAt: new Date('2023-03-13T06:00:00.000Z'),
  settings: {
    theme: 'dark',
    fontSize: 15,
    formOfContact: 'text'
  },
  phone: '8889991234'
}

console.log(BVON.serialize(user))

/*
prints: <ByteView(216) 09 08 06 06 08 02 69 64 10 08 
1c 32 4c 44 33 32 54 39 4e 42 50 4d 46 33 59 44 51 59 
4c 56 41 4e 4d 47 32 32 41 32 4a 06 08 04 6e 61 6d 65 
09 08 02 06 08 05 66 69 72 73 74 06 08 04 4d 69 6b 65 
06 08 04 6c 61 73 74 06 08 0a 57 69 6c 6c 69 61 6d 
...136 more bytes />
*/
```

#### with schema:
```js
import BVON, { UOID } from '@neumatter/bvon'

const user = {
  id: new UOID('2LD32T9NBPMF3YDQYLVANMG22A2J'),
  name: {
    first: 'Mike',
    last: 'Williamson'
  },
  createdAt: new Date('2023-03-02T06:00:00.000Z'),
  modifiedAt: new Date('2023-03-13T06:00:00.000Z'),
  settings: {
    theme: 'dark',
    fontSize: 15,
    formOfContact: 'text'
  },
  phone: '8889991234'
}

const userSchema = new BVON.Schema({
  id: 'UOID',
  name: {
    first: 'String',
    last: 'String'
  },
  createdAt: 'Date',
  modifiedAt: 'Date',
  settings: {
    theme: 'String',
    fontSize: 'Number',
    formOfContact: 'String'
  },
  phone: 'String'
})

console.log(BVON.serialize(user, userSchema))

/*
prints: <ByteView(143) 09 08 06 0e 08 01 10 08 1c 
32 4c 44 33 32 54 39 4e 42 50 4d 46 33 59 44 51 59 
4c 56 41 4e 4d 47 32 32 41 32 4a 0e 08 02 09 08 02 
0e 08 03 06 08 04 4d 69 6b 65 0e 08 04 06 08 0a 57 
69 6c 6c 69 61 6d 73 6f 6e 0e 08 05 08 00 ef e7 a0 
86 01 00 00 ...63 more bytes />
*/
```


### (method) `BVON.deserialize`:

Args [`data: any`, `schema?: BVON.Schema`]

If the data was serialized using a schema, it must also be deserialized with a schema.

Returns `any`

```js
import BVON from '@neumatter/bvon'

console.log(BVON.deserialize(serializedUser))

/*
{
  id: UOID('2LD32T9NBPMF3YDQYLVANMG22A2J'),
  name: { first: 'Mike', last: 'Williamson' },
  createdAt: 2023-03-02T06:00:00.000Z,
  modifiedAt: 2023-03-13T06:00:00.000Z,
  settings: { theme: 'dark', fontSize: 15, formOfContact: 'text' },
  phone: '8889991234'
}
*/
```
npm package: @neumatter/cookie-jar
Description: Module for working with cookies and/or signing and verifying cookies.
Author: Cal Young
Latest version: 1.0.2


# CookieJar
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

Module for working with cookies and/or signing and verifying cookies.
<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/cookie-jar
```

<br />

<a name="usage"></a>
## Usage


### CookieJar:

```js
import CookieJar from '@neumatter/cookie-jar'

const cookieJar = new CookieJar(req.get('cookie'))

cookieJar.set('id', {
  sameSite: true,
  httpOnly: true,
  strict: true
})
// ...use cookieJar
```


### Server Cookies:

```js
import { RequestCookies, ResponseCookies } from '@neumatter/cookie-jar'

const reqCookies = new RequestCookies(req)
const resCookies = new ResponseCookies(res) // Will set cookies automatically on Response

resCookies.set('id', {
  sameSite: 'lax',
  httpOnly: true,
  strict: true,
  maxAge: 'P2W' // 2 week duration string
})

resCookies.sign('id', secret) // Will update the value automatically on Response
```
npm package: @neumatter/enum
Description: A module for building Enums.
Author: Cal Young
Latest version: 1.1.1


# Enum
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#Usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/enum
```

<br />

<a name="Useage"></a>
## Building Enums

```js
import Enum from '@neumatter/enum'

class Color extends Enum {
  static Blue = new Color()
  static Green = new Color()
  static Red = new Color()
}

// Builds the objects and freezes all objects within Enum to prevent changes.
Color.build()

Color.Blue.is('Blue') // returns true
Color.Blue.is(0) // returns true
Color.Blue.is(Color.Blue) // returns true

Color.get('Blue') // returns { key: 'Blue', value: 0 }
Color.get(0) // returns { key: 'Blue', value: 0 }

Color.getKey('Blue') // returns 'Blue'
Color.getKey(0) // returns 'Blue'

Color.getValue('Blue') // returns 0
Color.getValue(0) // returns 0

Color.Blue.toString() // returns '0'

Color.Blue.toJSON() // returns 0
```


```js
import Enum from '@neumatter/enum'

// Useful if needing to deserialize Enum
class TmpColor extends Enum {}

// No need to call Enum.build when using Enum.initialize
const Color = TmpColor.initialize({
  Blue: 0,
  Green: 1,
  Red: 2
})

Color.Blue.is('Blue') // returns true
Color.Blue.is(0) // returns true
Color.Blue.is(Color.Blue) // returns true

Color.get('Blue') // returns { key: 'Blue', value: 0 }
Color.get(0) // returns { key: 'Blue', value: 0 }

Color.getKey('Blue') // returns 'Blue'
Color.getKey(0) // returns 'Blue'

Color.getValue('Blue') // returns 0
Color.getValue(0) // returns 0

Color.Blue.toString() // returns '0'

Color.Blue.toJSON() // returns 0
```
npm package: @neumatter/event-emitter
Description: An EventEmitter for client side and server side support.
Author: Cal Young
Latest version: 1.0.0


# EventEmitter
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

An EventEmitter for client side and server side support.

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/event-emitter
```

<br />

<a name="usage"></a>
## Usage


### constructor:
Args: `options?: { captureRejections?: boolean, maxListeners?: number }`

```js
import EventEmitter from '@neumatter/event-emitter'

// default options when undefined:
const eventEmitter = new EventEmitter({ captureRejections: false, maxListeners: 10 })
```


### addListener | on:
Args: `eventName: string, listener: (...args) => void`

```js
import EventEmitter from '@neumatter/event-emitter'

// default options when undefined:
const eventEmitter = new EventEmitter()

const errorHandler = (err) => {
  console.error(err)
}

eventEmitter.addListener('error', errorHandler)
```


### removeListener | off:
Args: `eventName: string, listener: (...args) => void`

```js
import EventEmitter from '@neumatter/event-emitter'

// default options when undefined:
const eventEmitter = new EventEmitter()

const errorHandler = (err) => {
  console.error(err)
}

eventEmitter.removeListener('error', errorHandler)
```


### emit:
Args: `eventName: string, ...args: any[]`

```js
import EventEmitter from '@neumatter/event-emitter'

// default options when undefined:
const eventEmitter = new EventEmitter()

eventEmitter.emit('error', new Error('error message'))
```
npm package: @neumatter/hooks
Description: A module for react/nextjs hooks.
Author: Cal Young
Latest version: 1.0.0-beta.7


# Hooks
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

A library of hooks for use in next.js.

<br />

## Table of Contents
- [ Installation ](#install)
- [ isClient ](#isClient)
- [ isDev ](#isDev)
- [ useAsyncEffect ](#useAsyncEffect)
- [ useBoolean ](#useBoolean)
- [ useCounter ](#useCounter)
- [ useDarkMode ](#useDarkMode)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/hooks
```

<br />

<a name="isClient"></a>
## isClient

```js
import { isClient } from '@neumatter/hooks'

if (isClient) {
  // use client
}
```

<br />

<a name="isDev"></a>
## isDev

```js
import { isDev } from '@neumatter/hooks'

if (isDev) {
  // use on development
}
```

<br />

<a name="useAsyncEffect"></a>
## useAsyncEffect

```js
import { useAsyncEffect } from '@neumatter/hooks'

useAsyncEffect(
  async () => {
    // run async function
  },
  [], // dependency list
  {
    signal // optional abort signal
  }
)
```

<br />

<a name="useBoolean"></a>
## useBoolean

```js
import { useBoolean } from '@neumatter/hooks'

const [state, actions] = useBoolean(false)
actions.toggle() // toggles boolean
actions.set(true) // sets boolean
actions.setTrue() // sets boolean to true
actions.setFalse() // sets boolean to false
```

<br />

<a name="useCounter"></a>
## useCounter

```js
import { useCounter } from '@neumatter/hooks'

const [state, actions] = useCounter(0, {
  min: 0, // optional minimum
  max: 9 // optional maximum
})

actions.increment()
actions.decrement()
actions.reset()
actions.set(5)
```

<br />

<a name="useDarkMode"></a>
## useDarkMode

```js
import { useDarkMode } from '@neumatter/hooks'

const darkMode = useDarkMode(
  'colorTheme', // localStorage key
  'data-theme' // html attribute
)

darkMode.enableSystemPreference() // enable user os system preference
darkMode.enable() // enable dark mode
darkMode.disable() // disable dark mode
darkMode.toggle() // toggle dark mode
darkMode.theme // returns 'dark' | 'light'
darkMode.value // returns true if darkMode enabled
darkMode.overridedSystem // returns true if user manually changed darkMode.
```
npm package: @neumatter/http-error
Description: HTTPError class.
Author: Cal Young
Latest version: 1.0.1


# HTTPError
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

HTTPError class.

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/http-error 
```

<br />

<a name="usage"></a>
## Usage


### uses:
```js
import HTTPError from '@neumatter/http-error'

throw new HTTPError(404, 'not found')
throw new HTTPError(404)
throw new HTTPError('not found')
```
npm package: @neumatter/intl
Description: Module to aid in intl.
Author: Cal Young
Latest version: 1.0.23


# Intl
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

Module for working with the intl web api. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
for details on exports.
npm package: @neumatter/is
Description: Module for type checking in javascript.
Author: Cal Young
Latest version: 1.1.1


# is/NeuType

Tool for better type checking in javascript. 
You can also create your own type for stricter type enforcement.

<br />

# Table of Contents
1. [ Install ](#install) <br />
2. [ Usage ](#examples) <br />

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/is
```

<br />

<a name="examples"></a>
## Usage


### Default:

```js
// CJS require
const is = require('@neumatter/is')
const { NeuType } = require('@neumatter/is')
// ESM import
import is, { NeuType } from '@neumatter/is'

is.array([]) // true
is.emptyArray([]) // true
is.falseType([]) // true

is.object({}) // true
is.emptyObject({}) // true

is.string('') // true
is.emptyString('') // true
is.falseType('') // true

is.boolean(false) // true

is.number(NaN) // true
is.NaN(NaN) // true

is.infinite(Infinite) // true

is.null(null) // true
is.falseType(null) // true

is.date(new Date()) // true

is.undefined(undefined) // true
is.falseType(undefined) // true

is.function(NeuType) // true
is.instance(new NeuType(), NeuType) // true

is.symbol(Symbol) // true
```


### Generating Types:

```js
// CJS require
const { NeuType } = require('@neumatter/is')
// ESM import
import { NeuType } from '@neumatter/is'

const arrType = new NeuType([{ hello: 'world' }])
arrType.tag // Array<Object>
arrType.is('Array') // true
arrType.instance(Array) // true
arrType.equals([{ random: 'obj' }]) // true | type must match Array<Object>

// Type From Class
class SomeClass {}
const someClassObj = new SomeClass()
const classObjType = new NeuType(someClassObj)
classObjType.tag // Object[SomeClass]
classObjType.is('Object') // true
classObjType.is('SomeClass') // true
classObjType.is(SomeClass) // true
classObjType.equals(SomeClass) // false
classObjType.new() // returns new instance of SomeClass
`${classObjType}` // Object[SomeClass]
'' + classObjType // Object[SomeClass]
console.log(classObjType) // NeuType [Object[SomeClass]] {}

is.array([]) // true
is.emptyArray([]) // true
is.falseType([]) // true

is.object({}) // true
is.emptyObject({}) // true

is.string('') // true
is.emptyString('') // true
is.falseType('') // true

is.boolean(false) // true

is.number(NaN) // true
is.NaN(NaN) // true

is.infinite(Infinite) // true

is.null(null) // true
is.falseType(null) // true

is.date(new Date()) // true

is.undefined(undefined) // true
is.falseType(undefined) // true

is.function(NeuType) // true
is.instance(new NeuType(), NeuType) // true

is.symbol(Symbol) // true
```
npm package: @neumatter/jwt
Description: Module for JWTs and JWKs.
Author: Cal Young
Latest version: 1.0.1


# JWT
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/jwt
```

<br />

<a name="usage"></a>
## Usage


### Signing:

```js
import { JWS, UnsecuredJWT } from '@neumatter/jwt'

const jwt = new UnsecuredJWT({ expiresIn: 'PT4H', id: '123456789' }, { alg: 'HS256' })
const jws = await JWS.sign(jwt, process.env.SECRET_JWT)
```


### Verifying:

```js
import { JWS } from '@neumatter/jwt'

const jws = new JWS(signedString)
const unsecuredJWT = await jws.verify(process.env.SECRET_JWT)
```
npm package: @neumatter/lru-cache
Description: A simple LRUCache with maxAge and allowStale options.
Author: Cal Young
Latest version: 1.0.0


# LRUCache
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

A simple LRUCache with maxAge and allowStale options.

<br />

## Table of Contents
- [ Installation ](#install)
- [ Usage ](#usage)

<br />

<a name="install"></a>
## Install

```console
npm i @neumatter/lru-cache
```

<br />

<a name="usage"></a>
## Usage


### `LRUCache`:

```ts
import LRUCache from '@neumatter/lru-cache'

type LRUCacheOptions = {
  maxSize?: number,
  maxAge?: number,
  allowStale?: boolean,
  sizeCalculation?: (value: any, key: any) => number,
  notFoundReturnValue?: any
}

// All Options set to default
const cache = new LRUCache({
  maxSize: 1e4,
  maxAge: Infinity,
  allowStale: false
  sizeCalculation: (value, key) => 1,
  notFoundReturnValue: undefined
})
```


### `LRUCache.get`:

```js
// All Options set to default
const value = cache.get('/key', { allowStale: false }) // returns value or cache.notFoundReturnValue
```


### `LRUCache.peek`:

Same as `LRUCache.get` but it doesn't change the order of the entries.

```js
// All Options set to default
const value = cache.peek('/key', { allowStale: false }) // returns value or cache.notFoundReturnValue
```


### `LRUCache.set`:

```js
cache.set('/key', 99)
```


### `LRUCache.clear`:

```js
cache.clear()
```


### `LRUCache.delete`:

```js
const isDeleted = cache.delete('/key') // returns boolean
```