composable-dot-box

1.0.4 • Public • Published

Object:

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.

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

Readme

Keywords

Package Sidebar

Install

npm i composable-dot-box

Weekly Downloads

6

Version

1.0.4

License

ISC

Last publish

Collaborators

  • mattcpchen