npm.io
1.0.0 • Published 7 years ago

hook-factory

Licence
MIT
Version
1.0.0
Deps
1
Size
4 kB
Vulns
0
Weekly
0

Hook Factory

Index

Installing

yarn add hook-factor

Usage

import Factory from "hook-factory";

const data = {
    count: 0
};

const modifier = ({
    prehook: data => {
        data.count++
        return data;
    },
    posthook: data => {
        data.count++
        return data;
    }
});

const modifiers = [modifier];

const newCount = factory({
    data,
    modifiers
});

console.log(newCount);
// { count: 2}