https://github.com/arlac77/model-attributes
attribute meta description
https://github.com/arlac77/model-attributes
meta-model
Last synced: 3 months ago
JSON representation
attribute meta description
- Host: GitHub
- URL: https://github.com/arlac77/model-attributes
- Owner: arlac77
- License: 0bsd
- Created: 2016-05-20T11:39:17.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2025-07-15T15:02:57.000Z (11 months ago)
- Last Synced: 2025-07-16T00:36:41.154Z (11 months ago)
- Topics: meta-model
- Language: JavaScript
- Homepage:
- Size: 2.43 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/model-attributes)
[](https://spdx.org/licenses/0BSD.html)
[](https://bundlejs.com/?q=model-attributes)
[](https://npmjs.org/package/model-attributes)
[](https://github.com/arlac77/model-attributes/issues)
[](https://actions-badge.atrox.dev/arlac77/model-attributes/goto)
[](https://github.com/prettier/prettier)
[](http://commitizen.github.io/cz-cli/)
[](https://snyk.io/test/github/arlac77/model-attributes)
[](https://coveralls.io/github/arlac77/model-attributes)
# model-attributes
attribute meta description
```javascript
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
* [setAttributes](#setattributes)
* [Parameters](#parameters)
* [getAttribute](#getattribute)
* [Parameters](#parameters-1)
* [getAttributes](#getattributes)
* [Parameters](#parameters-2)
* [createAttributes](#createattributes)
* [Parameters](#parameters-3)
* [mergeAttributes](#mergeattributes)
* [Parameters](#parameters-4)
## setAttributes
Copies attribute values from a source object into a destination object.
### Parameters
* `dest` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target object to be modified
* `atts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
* `src` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** origin of the data to be copied
* `cb` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** callback to be executed for each copied value
* `prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name prefix used for all attributes
Returns **void**
## getAttribute
Delivers a attribute value for a given attribute name
### Parameters
* `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** to query
* `atts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** attribute name
Returns **Any** attribute value
## getAttributes
Retrive attribute values from an object.
### Parameters
* `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute value source
* `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** values
## createAttributes
Create attributes from its definition.
### Parameters
* `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attributes
## mergeAttributes
Merge attribute definitions.
### Parameters
* `dest` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used also the merge target
* `atts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** merged definitions (dest)
# install
With [npm](http://npmjs.org) do:
```shell
npm install model-attributes
```
# license
# BSD-2-Clause