1.0.12 • Published 3 years ago

factri v1.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Factri

It is small set for util functions

Installation

Install factri with npm or yarn

npm i factri
yarn add factri

Functions List

NameDescription
factoryUsed for creating object instances
extendit is equivalent to extends keyword for class but here we can extend factory instances

Usage/Examples

factory

import { factory } from 'factri'

const Vehicle = factory((t) => {
  
    let fuel = 100 // private variable
  
    t.drive = () => fuel--
  
    t.checkFuel = () => console.log(fuel)
  
    t.refill = (f) => fuel += Math.min(f, 100 - fuel)
  
})

const vehicle = Vehicle()

vehicle.drive()
vehicle.drive()

vehicle.checkFuel() // 98

vehicle.refill(2) 

vehicle.checkFuel() // 100

Authors

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago