Nimoy Prospers Mystically

npm

Need private packages and team management tools?Check out npm Orgs. »

This package has been deprecated

Author message:

this package has been deprecated

celia.object

1.0.4 • Public • Published

celia.object

A modern JavaScript object utility library delivering modularity, performance, and extras.

NPM version NPM Downloads


Table of contents


Installation

Load celia.object via classical <script> tag

<script src="https://cdn.jsdelivr.net/npm/celia.object/iife.min.js"></script>
<script>
  // window.celiaObject
  celiaObject.assign
  celiaObject.forIn
  celiaObject.forOwn
  celiaObject.get
  celiaObject.map
  celiaObject.set
</script> 

Only LinkedMap

<script src="https://cdn.jsdelivr.net/npm/celia.object/LinkedMap.iife.min.js"></script>
<script>
  // window.LinkedMap
  var map = new LinkedMap();
</script> 

CommonJS style with npm

npm install celia.object --save
 
// es6
import { assign, forIn, forOwn, get, map, set, LinkedMap } from 'celia.object';
import { assign, forIn, forOwn, get, map, set, LinkedMap } from 'celia.object/es';
 
// modularity
import assign from 'celia.object/es/assign';
import forIn from 'celia.object/es/forIn';
import forOwn from 'celia.object/es/forOwn';
import get from 'celia.object/es/get';
import map from 'celia.object/es/map';
import set from 'celia.object/es/set';
import LinkedMap from 'celia.object/es/LinkedMap';
 
// node
const { assign, forIn, forOwn, get, map, set } = require('celia.object');
// or
const assign = require('celia.object/assign');
const forIn = require('celia.object/forIn');
const forOwn = require('celia.object/forOwn');
const get = require('celia.object/get');
const map = require('celia.object/map');
const set = require('celia.object/set');
const LinkedMap = require('celia.object/LinkedMap');
 

Usage

Modules

  • assign
  • forIn
  • forOwn
  • get
  • map
  • set
  • LinkedMap

LinkedMap Instance Method Summary

LinkedMap实例方法

Modifier and Type Instance Methods Description
this clear() Clears this property list so that it contains no keys.
清空属性集合对象内的key和value。
LinkedMap clone() Creates a shallow copy of this property list.
浅克隆一个属性集合对象。
Boolean containsKey​(key)

key: String
Tests if the specified object is a key in this property list.
检测是否包含指定key。
Boolean containsValue​(value)

value: any
Returns true if this property list maps one or more keys to this value.
检测是否包含指定value。
this forEach(callback)

callback: Function
Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
遍历属性集合,在回调函数中返回包含value和key的数组。
any get​(key [, defaultValue])

key: String
defaultValue: any(optional)
Returns the value to which the specified key is mapped, or undefined if this map contains no mapping for the key.
根据指定的key返回对应的value,如果未匹配到就返回默认值或者undefined。
Boolean isEmpty​() Tests if this property list maps no keys to values.
判断是否是空集合。
Array<String> keys​() Returns an array of the keys in this property list.
返回所有的key
this put​(key, value)
set​(key, value)

key: String
value: any
Maps the specified key to the specified value in this property list.
暂存key和value至属性集合。
Number putAll​(t)

t: Object | Array
Copies all of the mappings from the specified map to this property list.
把数组或者对象浅拷贝至属性集合。
Boolean remove​(key [, specifiedValue])
delete​(key [, specifiedValue])

key: String
specifiedValue: any(optional)
Removes the entry for the specified key or even it is mapped to the specified value.
移除指定的key的映射或者也包含指定的value才被移除。
Boolean replace​(key, newValue)

key: String
newValue: any
Replaces the entry for the specified key only if it is currently mapped to some value.
替换已存在的指定的key的映射。
Number size​() Returns the number of keys in this property list.
属性集合内key的数量
Array values​() Returns a Array of the values contained in this map.
返回所有的value
const map = new LinkedMap();
map.put('key', 'value');
 
map.putAll({
  key2: 'value2',
  key3: 'value3'
});
map.putAll([
  ['key4', 'value4'],
  ['key5', 'value5']
]);
 
map.forEach((value, key) => {
  
});
 
for (let [key, value, index] of map) {
  
}
 

install

npm i celia.object

Downloadsweekly downloads

44

version

1.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability