GithubHelp home page GithubHelp logo

composable-dot-box's Introduction

Objective:

The "composable-dot-box" object allows you to wrap your data in composable and immutable getters and setters.

Composability is a system design principle that deals with the inter-relationships of components. It allows the users to select and assemble data in nested structures. Immutability will make sure the setter will only return copies of your source data without changing them.

node module: https://www.npmjs.com/package/composable-dot-box (npm install composable-dot-box)
document url: https://composable-dot-box-doc.herokuapp.com/

Methods:

  • of
  • map
  • mapTo
  • reduce
  • fork
  • print

Examples:

Example 1: dealing with string ``` const currentCharacterData = '64_32_41' const nextCharacter = DotBox .of(currentCharacterData) .map(str => new Number(str.split('_')[0])) .map(number => number +1) .map(nextNum => String.fromCharCode(nextNum)) .print(); ```

example 2: dealing with object

    const myData = {
      firstName: 'Matt',
      middleName: 'CP',
      lastName: 'Chen',
      height: '6\'',
      weight: '165',
      location: 'New York'
    };
    
    const myHealthStatus = DotBox
      .of(myData)
      .map(data => ({
        name: data.firstName +' '+data.middleName +' '+data.lastName,
        weight: data.weight
      }))
      .map(data => {
        const name = data.name;
        const isFatorNot = Number(data.weight)>160? 'fat' : 'skinny';
        return name + ', you are too ' + isFatorNot;
      })
      .print();
    
    // Matt CP Chen, you are too fat

composable-dot-box's People

Contributors

chipclnchen avatar

Watchers

 avatar  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.