open-index/open-npm huggingface dataset:
npm package: @neumatter/null-object
Description: A module for creating a NullObject that only has index and length properties.
Author: Cal Young
Latest version: 1.0.1


# NullObject
Create a null prototype Object. The created object will have no methods.
[![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/null-object
```

<br />

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

```js
import NullObject from '@neumatter/null-object'

const nullObject = new NullObject()
// use nullObject
```
npm package: @neumatter/object-cache
Description: Module for creating ObjectCaches that can be garbage collected.
Author: Cal Young
Latest version: 1.0.0


# ObjectCache
![plot](https://img.shields.io/npm/v/%40neumatter%2Fobject-cache?style=for-the-badge&labelColor=black)
![plot](https://img.shields.io/npm/dt/%40neumatter%2Fobject-cache?style=for-the-badge&labelColor=black)
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

Module for creating ObjectCaches that can be garbage collected.
The ObjectCache will delete the least-recently-used entry to make room for new entries.

<br />

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

<br />

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

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

<br />

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

```js
import ObjectCache from '@neumatter/object-cache'

class CustomObject {
  constructor () {}

  get () {
    const objectCache = ObjectCache.from(this, { maxSize })
    let value = objectCache.get('key')

    if (value === undefined) {
      value = someExpensiveOp()
      objectCache.set('key', value)
    }

    return value
  }
}
```
npm package: @neumatter/random-bytes
Description: Random Bytes function. Works in node and browser.
Author: Cal Young
Latest version: 1.0.5


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

Random Bytes function. Works in nodejs and browser.

<br />

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

<br />

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

```console
npm i @neumatter/random-bytes 
```

<br />

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


### sync:

```js
import randomBytes from '@neumatter/random-bytes'

const byteView = randomBytes(32)
// ...use byteView
```


### callback:

```js
import randomBytes from '@neumatter/random-bytes'

randomBytes(32, (err, byteView) => {
  if (err) {
    console.error(err)
  } else {
// ...use byteView
  }
})
```
npm package: @neumatter/random-fill
Description: Random Fill function. Works in node and browser.
Author: Cal Young
Latest version: 1.0.0


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

Random Fill function. Works in nodejs and browser.

<br />

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

<br />

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

```console
npm i @neumatter/random-fill
```

<br />

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


```js
import randomFill from '@neumatter/random-fill'

const view = new Uint8Array(32)
randomFill(view)
// ...use view
```


```js
import randomFill from '@neumatter/random-fill'
import ByteView from 'byteview'

const view = ByteView.alloc(32)
randomFill(view)
// ...use view
```


```js
import randomFill from '@neumatter/random-fill'

const view = Buffer.allocUnsafe(32)
randomFill(view)
// ...use view
```


```js
import randomFill from '@neumatter/random-fill'

const view = new Uint16Array(16)
randomFill(view)
// ...use view
```
npm package: @neumatter/safe-collections
Description: Safe iterable collections.
Author: Cal Young
Latest version: 1.0.0


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

Safe Collections module that replicates nodejs SafeMap, SafeSet, SafeWeakMap.

<br />

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

<br />

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

```console
npm i @neumatter/safe-collections 
```

<br />

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

```js
import { SafeMap, SafeSet, SafeWeakMap } from '@neumatter/safe-collections'

// Use SafeMap, SafeSet, SafeWeakMap
```
npm package: @neumatter/slot-map
Description: Create private fields using a SlotMap. Similar to internal slots.
Author: Cal Young
Latest version: 1.0.2


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

Create private fields using a SlotMap. Similar to internal slots.

<br />

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

<br />

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

```console
npm i slot-map
```

<br />

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


### static `SlotMap.get`:

Gets or creates the SlotMap for the given object.

```js
import SlotMap from 'slot-map'

const obj = {}
const slotMap = SlotMap.get(obj)
```


### static `SlotMap.set`:

Sets the SlotMap for the given object.

```js
import SlotMap from 'slot-map'

const obj = {}
SlotMap.set(obj, slotMap)
```


### static `SlotMap.setInternal`:

Sets a property in the SlotMap for the given object.

```js
import SlotMap from 'slot-map'

const obj = {}
SlotMap.setInternal(obj, 'id', '01234')
```


### static `SlotMap.getInternal`:

Gets a property in the SlotMap for the given object.

```js
import SlotMap from 'slot-map'

const obj = {}
SlotMap.getInternal(obj, 'id')
```
npm package: @neumatter/stateless-session
Description: Module for using encrypted stateless sessions.
Author: Cal Young
Latest version: 1.0.1


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

Module for using encrypted stateless sessions.
<br />

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

<br />

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

```console
npm i @neumatter/stateless-session
```

<br />

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


### StatelessSession.get:

```js
import StatelessSession from '@neumatter/stateless-session'

const session = await StatelessSession.get(
  req,
  res,
  {
    secret: process.env.SESSION_SECRET,
    cookieName: 'appSession',
    cookieOptions: {
      maxAge: 'P2W2H',
      sameSite: true,
      secure: process.env.NODE_ENV === 'production'
    }
  }
)

session.user = { isLoggedIn: false, admin: false }

await session.save()
```
npm package: @neumatter/to-camel-case
Description: Module for converting strings, arrays, and object keys to camelCase.
Author: Cal Young
Latest version: 1.0.1


# toCamelCase

Tool for converting strings, arrays, and object keys to strings.

<br />

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

<br />

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

```console
npm i @neumatter/to-camel-case 
```

<br />

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


### Default:

```js
// CJS require
const toCamelCase = require('@neumatter/to-camel-case')
// ESM import
import toCamelCase from '@neumatter/to-camel-case'

/** 
 *
 * @param {string}
 * @returns {string} helloWorld
*/
toCamelCase('hello-world') 
/** 
 *
 * @param {string}
 * @returns {string} helloWorld
*/
toCamelCase('hello_world'))
/** 
 *
 * @param {string}
 * @returns {string} helloWorld
*/
toCamelCase('hello world'))
/** 
 *
 * @param {string}
 * @returns {string} helloWorld
*/
toCamelCase('hello\nworld'))
/** 
 *
 * @param {string[]}
 * @returns {string[]} [ 'helloWorld1', 'helloWorld2', [ 'helloWorld1', 'helloWorld2' ] ]
*/
toCamelCase(['hello\nworld1', 'hello world2', ['hello_world1', 'hello-world2']]))
/** 
 *
 * @param {object}
 * @returns {object} { helloWorld1: 'hi', helloWorld2: 'hi', helloWorld3: { helloWorld4: 'hi', helloWorld5: 'hi' } }
*/
toCamelCase({
  hello_world1: 'hi',
  'hello world2': 'hi',
  hello__world3: {
    hello_world4: 'hi',
    'hello world5': 'hi'
  }
})
```
npm package: @neumatter/uid
Description: Module for generating unique ids.
Author: Cal Young
Latest version: 1.0.0


# Uid

Module for generating unique ids.

<br />

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

<br />

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

```console
npm i @neumatter/uid 
```

<br />

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


```js
import Uid from '@neumatter/uid'

const uid = await Uid.generate()
console.log(uid) // prints [Uid => l6dnuuo9huq5I9ld95OCg9dhC8S6ugUq9]
console.log(uid.toString()) // prints l6dnuuo9huq5I9ld95OCg9dhC8S6ugUq9
console.log(uid.date) // prints 2022-08-03T13:44:30.921Z
```


```js
import Uid from '@neumatter/uid'

const uid = await Uid.generate({ size: 12 })
console.log(uid) // prints [Uid => l6dwi29zOSlOAuONyClN]
console.log(uid.toString()) // prints l6dwi29zOSlOAuONyClN
console.log(uid.date) // prints 2022-08-03T17:46:30.791Z
```


```js
import Uid from '@neumatter/uid'

const uid = await Uid.generate({ prefix: 'v1' })
console.log(uid) // prints [Uid => v1-l6dwkh88sSCL68UOggIZ6dhQnZRcStzRS]
console.log(uid.toString()) // prints v1-l6dwkh88sSCL68UOggIZ6dhQnZRcStzRS
console.log(uid.date) // prints 2022-08-03T17:48:23.480Z
```
npm package: @neumatter/uri
Description: URI class that can be used on relative URIs.
Author: Cal Young
Latest version: 1.0.0


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

URI class that can be used on relative URIs.

<br />

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

<br />

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

```console
npm i @neumatter/uri
```

<br />

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

```js
import URI from '@neumatter/uri'

const uri = new URI('https://example.com/schemas/address#/properties/street_address')
// do something with uri
```

```js
import URI from '@neumatter/uri'

const uri = new URI('#/properties/street_address')
// do something with uri
```

```js
import URI from '@neumatter/uri'

const uri = new URI('/schemas/address')
// do something with uri
```
npm package: @neumatter/url
Description: Extends the URL class to make an easier to work with URL API.
Author: Cal Young
Latest version: 1.0.0


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

Extends the URL class to make an easier to work with URL API.

<br />

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

<br />

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

```console
npm i @neumatter/url
```

<br />

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


### constructor (class) `NeuURL`:

Args [`url: string | URL | NeuURL | undefined, base: string | URL | NeuURL | undefined`]

```js
import NeuURL from '@neumatter/url'

const url = new NeuURL('/path/subdir')
const url = new NeuURL('https://localhost:3000/path/subdir')
const url = new NeuURL()
```
npm package: @neumatter/utilities
Description: Utility package for copying case, getting values from option objects, and asserting types.
Author: Cal Young
Latest version: 1.0.3


# Utilities
[![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/utilities
```

<br />

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


### Import

```js
import * as utilities from '@neumatter/utilities'
// use utilities
```


### `utilities.getCasePattern`:

```ts
utilities.getCasePattern(input: string): ByteView
```


### `utilities.applyCasePattern`:

```ts
utilities.applyCasePattern(input: string, pattern: ByteView): string
```


### `utilities.throwIfNotWithin`:

```ts
utilities.throwIfNotWithin<T extends any>(
  value: T,
  availableValues?: Array<T>
): void
```


### `utilities.throwIfNoInstanceOf`:

```ts
utilities.throwIfNoInstanceOf<T extends any>(
  value: T,
  availableValues?: Array<typeof T>
): void
```


### `utilities.assertObject`:

```ts
utilities.assertObject<T extends object>(
  input: T,
  paramName: string
): void
```


### `utilities.assertString`:

```ts
utilities.assertString(input: string, paramName: string): void
```


### `utilities.assertFunction`:

```ts
utilities.assertFunction(input: Function, paramName: string): void
```


### `utilities.assertNumber`:

```ts
utilities.assertNumber(input: number, paramName: string): void
```


### `utilities.assertFiniteNumber`:

```ts
utilities.assertFiniteNumber(input: number, paramName: string): void
```


### `utilities.getObjectOption`:

```ts
utilities.getObjectOption<O extends object, T>(
  opts: O,
  prop: keyof O,
  values?: Array<any>,
  fallback: T
): T
```


### `utilities.getBooleanOption`:

```ts
utilities.getBooleanOption<O extends object>(
  opts: O,
  prop: keyof O,
  fallback: boolean
): boolean
```


### `utilities.getStringOption`:

```ts
utilities.getStringOption<O extends object>(
  opts: O,
  prop: keyof O,
  values?: Array<string>,
  fallback: string
): string
```


### `utilities.defaultNumberOption`:

```ts
utilities.defaultNumberOption(
  val: number,
  min: number,
  max: number,
  fallback: number
): number
```


### `utilities.getNumberOption`:

```ts
utilities.getNumberOption<O extends object>(
  options: O,
  property: keyof O,
  minimum: number,
  maximum: number,
  fallback: number
): number
```


### `utilities.defaultIntegerOption`:

```ts
utilities.defaultIntegerOption(
  val: number,
  min: number,
  max: number,
  fallback: number
): number
```


### `utilities.getIntegerOption`:

```ts
utilities.getIntegerOption<O extends object>(
  options: O,
  property: keyof O,
  minimum: number,
  maximum: number,
  fallback: number
): number
```
npm package: @neumatter/webc
Description: Module to extend and use web components.
Author: Cal Young
Latest version: 1.1.1


![plot](https://github.com/Clyng57/neumatter/raw/main/public/neumatter-logo-blackBG-01.svg)
<br />

A module for creating Web Components.

<br />

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

```console
npm i @neumatter/webc
```

<br />

<a name="getting-started"></a>
## Getting Started

```js
import * as webC from '@neumatter/webc'

class ThemeButton extends webC.WebComponent {
  constructor () {
    // always call super first
    super()

    const theme = localStorage.getItem('data-theme')
    const { matches: prefersDark } = matchMedia('(prefers-color-scheme: dark)')

    // the context that will be used to alter element
    this.context.dark = 'bi-sun-fill'
    this.context.light = 'bi-moon-fill'

    // set the theme state if found in storage or prefersDarkMode
    this.state.theme = theme ? theme : prefersDark ? 'dark' : 'light'
    // use the state.theme as the key to get context and set state.themeClass
    this.state.themeClass = this.context[this.state.theme]
  }

  // render will be called on load and state changes
  // renders the doc
  render () {
    const root = document.documentElement
    const { theme } = this.state
    root.setAttribute('data-theme', theme)
    localStorage.setItem('data-theme', theme)

    return `
        <i id="btni" class="bi ${this.state.themeClass}"></i>
      `
  }

  // on['Event'] - adds eventListener
  onClick = () => {
    // change the theme
    const theme = this.state.theme === 'dark' ? 'light' : 'dark'
    // setState
    this.setState({
      theme,
      themeClass: this.getContext(theme)
    })
  }
}

webC.define('theme-button', ThemeButton)
```