collection-wrapper

0.1.2 • Public • Published

Collection Wrapper

A basic library to help you create collection(collect.js) variants, for example form fields or table columns. Establish behavior and manipulate collections in dedicated classes. Keeping your code clean and comprehensible.

Install

yarn add collection-wrapper

Usage

Define a 'ExampleFields' class, and get the defined 'toCreate' variant:

import { Fields } from 'collection-wrapper'

export default class ExampleFields extends Fields {
  
  fields() {
    return [
      {
        name: 'name',
        type: 'text-field',
        prop: {
          label: 'Name'
        },
      },
      {
        name: 'last_name',
        type: 'text-field',
        prop: {
          label: 'Last name'
        },
      },
    ]
  }
  
  static toCreate() {
    return this.reduce('name', ['name'])
  }
}

Use the defined 'ExampleFields' class with the 'toCreate' variant:

import ExampleFields from './example.fields.js'

var fields = ExampleFields.toCreate()

The result of 'toCreate' variant is:

[
  {
    name: 'name',
    type: 'text-field',
    prop: {
      label: 'Name'
    },
  }
]

Dependents (0)

Package Sidebar

Install

npm i collection-wrapper

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

10.2 kB

Total Files

7

Last publish

Collaborators

  • dicalj