Skip to content

JamesGelok/inity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inity

✨ Custom Magic Initializers 🧙

Installation

Yarn

yarn add inity

npm

npm install inity

Usage

import Init from "inity";

// Sample class that holds a value
class Value {
  constructor(n) {
    this.n = n;
  }
}

✨ Initialize many values using destructuring assignment syntax... 🧙

const { posX, posY, velX, velY, score, state } = new Init(Value)(0);
/* each variable has its own UNIQUE value class */

posX.n = 42;
console.log(`${posX.n}, ${posY.n}`);
// 15, 0

💩 ...rather than in a big block...

const posX = new Value(0);
const posY = new Value(0);
const velX = new Value(0);
const velY = new Value(0);
const score = new Value(0);
const state = new Value(0);

About

✨ Custom Magic Initializers 🧙

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published