New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@caliatys/object-helper

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@caliatys/object-helper

Manage your objects easily

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
2
Created
Source

Build Status Coverage Status

Object Helper

JavaScript helper for object management.

Demo with RunKit

Installation

npm install @caliatys/object-helper --save

Import

JavaScript

let ObjectHelper = require('@caliatys/object-helper').ObjectHelper;

TypeScript

import { ObjectHelper } from '@caliatys/object-helper';

Usage

MergeObjects

var defaultConfig = {
  flipped: false,
  isFixedToCamera: false,
  healthBar: {
    x: 0,
    y: 0
  }
};

var customConfig = {
  isFixedToCamera: true,
  healthBar: {
    y: 10
  }
};

let config = ObjectHelper.mergeObjects(defaultConfig, customConfig);

// {
//   flipped: false,
//   healthBar: { x: 0, y: 10 },
//   isFixedToCamera: true
// }

FilterObjectsByKey

let data = {
  CURSOR_1_UP    : { id: 'up',    key: '1' },
  CURSOR_1_DOWN  : { id: 'down',  key: '2' },
  CURSOR_1_LEFT  : { id: 'left',  key: '3' },
  CURSOR_1_RIGHT : { id: 'right', key: '4' },
  TECH_2_BLOCK   : { id: 'block', key: 'b' },
};

let objects = ObjectHelper.filterObjectsByKey(data, 'CURSOR', ['UP', 'LEFT']);

// [
//   { id: "down",  key: "2" },
//   { id: "right", key: "4" }
// ]

SearchTree

var tree = [{
  title: 'topNode',
  children: [{
    title: 'node1',
    children: [{
      title: 'randomValue1'
    }, {
      title: 'node2',
      children: [{
        title: 'randomValue2',
        children: [{
          title: 'node3',
          children: [{
            title: 'randomValue3'
          }]
        }]
      }]
    }]
  }]
}];

let nodes = ObjectHelper.searchTree(tree, 'children', 'title', 'randomValue2');

// {
//   title: "randomValue2",
//   children: [{
//     title: "node3",
//     children: [{
//        title: 'randomValue3'
//      }]
//   }]
// }

Test

npm run test

FAQs

Package last updated on 24 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts