JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q64658F
  • License MIT

An npm with various functions to manage objects.

Package Exports

  • object.mn

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (object.mn) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Object.mn

An npm with various functions to manage objects.

NPM version NPM downloads

NPM Banner

Installation:

npm install object.mn --save

yarn add object.mn

Functions:

Name Params
set Object path values callback
get Object path callback
delete Object path callback
has Object path callback
push Object path values callback
keys Object path callback
toJSON Object path callback
values Object path callback
entries Object path callback

Examples:

Set:

const
  object = require('object.mn'),
  data = {};
  
// No callback:
object.set(data, 'npm/object.mn', 'best');
console.log(data); // Output: { npm: { 'object.mn': 'best' } }

// With callback:
object.set(data, 'npm/object.mn', 'best', function(values) {
  return console.log(values);  // Output: { npm: { 'object.mn': 'best' } }
});

Get:

const
  object = require('object.mn'),
  data = { npm: { 'object.mn': 'best' } };
  
// No callback:
console.log(object.get(data, 'npm'));

// With callback:
object.get(data, 'npm', function(values) {
  return console.log(values);  // Output: { 'object.mn': 'best' } 
});

Delete:

const
  object = require('object.mn'),
  data = {
    npm: { 'object.mn': 'best' },
    key: 'value'
  };;
  
// No callback:
console.log(object.delete(data, 'key'));  // Output: { npm: { 'object.mn': 'best' } }

// With callback:
object.delete(data, 'key', function(values) {
  return console.log(values);  // Output: { npm: { 'object.mn': 'best' } }
});

Has:

const
  object = require('object.mn'),
  data = { key: 'value', key2: 'value2' };
  
// No callback:
console.log(object.has(data, 'key')); // Output: true
console.log(object.has(data, 'key3')); // Output: false

// With callback:
object.has(data, 'key', function(value) {
  return console.log(value); // Output: true
});

object.has(data, 'key3', function(value) {
  return console.log(value); // Output: false
});

Push:

const
  object = require('object.mn'),
  data = {};
  
// No callback:
object.push(data, 'array', 'values');
console.log(data); // Output: { array: [ 'values' ] }

// With callback:
object.push(data, 'array', 'values', function(values) {
  return console.log(values); // Output: { array: [ 'values' ] }
});

Keys:

const
  object = require('object.mn'),
  data = {
    key: 'value',
    values: {
      key2: 'value'
    }
  };
  
// No callback:
console.log(object.keys(data, '/')); // Output:  ['key', 'values']

// With callback:
object.keys(data, '/', function(values) {
  return console.log(values); // Output: ['key', 'values']
});

ToJSON:

const
  object = require('object.mn'),
  data = { npm: { 'object.mn': 'best' } };
  
// No callback:
console.log(object.toJSON(data, '/')); // Output: {"npm":{"object.mn":"best"}}

// With callback:
object.toJSON(data, '/', function(values) {
  return console.log(values); // Output: {"npm":{"object.mn":"best"}}
});

Values:

const
  object = require('object.mn'),
  data = { npm: { 'object.mn': 'best' } };
    
  // No callback:
  console.log(object.values(data, '/')); // Output: [ { 'object.mn': 'best' } ]
  
  // With callback:
  object.values(data, '/', function(values) {
    return console.log(values); // Output: [ { 'object.mn': 'best' } ]
  });

Entries:

const
  object = require('object.mn'),
  data = { npm: { 'object.mn': 'best' } };
    
  // No callback:
  console.log(object.values(data, '/')); // Output: [ [ 'npm', { 'object.mn': 'best' } ] ]
  
  // With callback:
  object.values(data, '/', function(values) {
    return console.log(values); // Output: [ [ 'npm', { 'object.mn': 'best' } ] ]
  });