Code Monkey home page Code Monkey logo

jet-set's Introduction

JetSet

A micro library for getting, setting, and watching object properties.


Installation

npm install --save jet-set

Usage Highlights

Here's JetSet's quick/dirty expressed in code; check out the full documentation for a deeper dive.

import jetSet from 'jet-set';

let fruitBasket = jetSet({
  apples: 3,
  oranges: 5,
  bananas: 6,
});

fruitBasket.limes = 4;
fruitBasket.lemons = 2;

// no big deal so far? let's add a derived/dynamic property
fruitBasket.totalFruit = () => {
  let sum = 0;

  for (let fruit in fruitBasket) {
    sum += fruitBasket[fruit];
  }

  return sum;
};

console.log(fruitBasket.totalFruit); // 20

// watch for changes, even on dynamic properties
const buyMoreCitrus = () => {
  const { oranges, limes, lemons } = fruitBasket;

  if (oranges < 2 || limes < 2 || lemons < 2) {
    console.log('Buy more citrus!');
  }
};

fruitBasket.onChange('totalFruit', buyMoreCitrus);

fruitBasket.lemons = 1; // > "Buy more citrus!"

About JetSet

This library aims to be three things: simple, tiny, and stateful.

  • Interacting with a JetSet object should feel familiar, mirroring how you set and get properties on a vanilla JavaScript object.
  • It's 496 bytes with no dependencies.
  • It treats derived/dynamic properties as static snapshots, making it great for managing state.

Deeper details can be found in the official documentation.

Bugs and Feature Requests

JetSet is a fledgling project. If you want to contribute or report an issue, please do! It's all tracked via GitHub.

Report an Issue/Bug

jet-set's People

Contributors

phillipluther avatar

Stargazers

kryptish avatar

Watchers

 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.