1.0.12 • Published 2 years ago

factri v1.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
2 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

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago