<commit_before># IVH Model

> Models for JavaScript

Super lightweight and largely inspired by ExtJS data models.

`IvhModel` allows you to convert value objects into robust, immutable models.
It protects your app from API changes and provides a nice abstraction layer for
business entities.

## Getting Started

Install with npm:

```
npm install --save ivh-model
```

Now get `IvhModel` via commonjs or es6 imports:

```javascript
const IvhModel = require('ivh-model')

// or

import IvhModel from 'ivh-model'
```

## Usage

Typical use invovles extending `IvhModel` and declaring your model's fields.
All model constructors accept a single options hash. For example:

```javascript
// Basic usage
class Thing1 extends IvhModel {
  // All model attributes are found by looking up options of the same name. Note
  // this is an accessor method.
  static get fields() {
    return [
      'id',
      'alias',
      'power'
    ]
  }
}

const opts = {
  id: 123,
  alias: 'Vageta',
  power: 550
}

// Using "new"
const t1 = new Thing1(opts)

// Using IvhMode.create
const t2 = Thing1.create(opts)

// IvhMode.create also works when handed off to e.g. Array.prototype.map
const models = [opts, opts].map(IvhModel.create())

t1.get('alias')
// --> 'Vageta'

t2.get('power')
// --> 550

// Fancy fields
class Thing2 extends IvhModel {
  static get fields() {
    return [
      // Fields can be pulled from options of the same name...
      'id',

      // .. or somewhere else entirely...<commit_msg>docs: Can just pass IvhModel.create<commit_after># IVH Model

> Models for JavaScript

Super lightweight and largely inspired by ExtJS data models.

`IvhModel` allows you to convert value objects into robust, immutable models.
It protects your app from API changes and provides a nice abstraction layer for
business entities.

## Getting Started

Install with npm:

```
npm install --save ivh-model
```

Now get `IvhModel` via commonjs or es6 imports:

```javascript
const IvhModel = require('ivh-model')

// or

import IvhModel from 'ivh-model'
```

## Usage

Typical use invovles extending `IvhModel` and declaring your model's fields.
All model constructors accept a single options hash. For example:

```javascript
// Basic usage
class Thing1 extends IvhModel {
  // All model attributes are found by looking up options of the same name. Note
  // this is an accessor method.
  static get fields() {
    return [
      'id',
      'alias',
      'power'
    ]
  }
}

const opts = {
  id: 123,
  alias: 'Vageta',
  power: 550
}

// Using "new"
const t1 = new Thing1(opts)

// Using IvhMode.create
const t2 = Thing1.create(opts)

// IvhMode.create also works when handed off to e.g. Array.prototype.map
const models = [opts, opts].map(IvhModel.create)

t1.get('alias')
// --> 'Vageta'

t2.get('power')
// --> 550

// Fancy fields
class Thing2 extends IvhModel {
  static get fields() {
    return [
      // Fields can be pulled from options of the same name...
      'id',

      // .. or somewhere else entirely...
{'fraction_non_alphanumeric': 0.10809018567639257, 'fraction_numerical': 0.011936339522546418, 'mean_word_length': 3.121584699453552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1480053', 'n_tokens_mistral': 994, 'n_tokens_neox': 925, 'n_words': 369}