Giter Club home page Giter Club logo

getter.js's Introduction

version Build Status Coverage

Getter.js

The Promise based get object parameters for the modern browsers and node.

Installation

$ npm install --save getter.js

Before

var dataObj = {
  test: 'testString',
  test2: 'testString2',
  getTest: () => {
    const self = this;
    return new Promise(resolve => resolve(self.test));
  },
  getTest2: () => {
    const self = this;
    return new Promise(resolve => resolve(self.test2));
  }
}

dataObj
  .getTest()
  .then(response => console.log(response));

After

import getter from 'getter.js'

let dataObj = {
  test: 'testString',
  test2: 'testString2'
};
dataObj = getter(dataObj);

const asyncTestValue = await dataObj.getTest();


let config = {
  async: false,
  multiple: false
};
dataObj = getter(dataObj, config);
const testValue = dataObj.get('test');

API

getter({Object} Object, {Object} [Config])

Object - provided argument where you want to add get functions. Config - provided configuration object for additional options Config.async - default true - getter functions returns Promise Config.multiple - default true - if true you would add to object x getKey functions if false you would get only get('key') function

getter.js's People

Stargazers

Bitcollage avatar Linus Lundahl avatar Song Liu avatar Mamoru Amano avatar Brian Yang avatar Michael Scott Hertzberg avatar  avatar

Watchers

James Cloos avatar Marcin Mrotek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.