npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

model-attributes

4.0.0 • Public • Published

npm Greenkeeper semantic-release styled with prettier Build Status codecov.io Coverage Status Known Vulnerabilities GitHub Issues Stories in Ready Dependency Status devDependency Status docs XO code style downloads Commitizen friendly

model-attributes

attribute meta description

const { createAttributes } from 'model-attributes';
 
const attributes = ma.createAttributes({
  att1: {},
  att2: { datault: 2}
});
 
const object = {};
 
ma.setAttributes(object, attributes, {
  att1: 'value1'
});
 
console.log(object.att1); // value1
console.log(object.att2); // 2

API

Table of Contents

model-attributes

setAttributes

Copies attribute values from a source object into a destination object.

Parameters

  • dest Object target object to be modified
  • atts Object attribute definitions to be used
  • src Object origin of the data to be copied
  • cb function callback to be executed for each copied value
  • prefix string name prefix used for all attributes

Returns undefined

getAttribute

Delivers a attribute value for a given attribute name

Parameters

  • object Object to query
  • atts Object attribute definitions to be used
  • path string attribute name

Returns Any attribute value

getAttributes

Retrive attribute values from an object

Parameters

  • object Object attribute value source
  • attributes Object
  • options Object (optional, default {})

Returns Object values

createAttributes

Create attributes from its definition

Parameters

Returns Object attributes

mergeAttributes

Merge attribute definitions

Parameters

  • dest Object attribute definitions to be used also the merge target
  • atts Object attribute definitions to be used

Returns Object merged definitions (dest)

install

With npm do:

npm install model-attributes

license

BSD-2-Clause

install

npm i model-attributes

Downloadsweekly downloads

166

version

4.0.0

license

BSD-2-Clause

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability