All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.datas.js Maven / Gradle / Ivy

There is a newer version: 3.14.1
Show newest version

let datas = {}

export function data(name, callback) {
    datas[name] = callback
}

export function injectDataProviders(obj, context) {
    Object.entries(datas).forEach(([name, callback]) => {
        Object.defineProperty(obj, name, {
            get() {
                return (...args) => {
                    return callback.bind(context)(...args)
                }
            },

            enumerable: false,
        })
    })

    return obj
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy