'use strict';

var tslib_es6 = require('../tslib.es6-8WCaSy-x.js');
var functions_isType = require('./is-type.js');

function hookAsyncData(init) {
    const initPromise = functions_isType.isPromise(init) ? init : init();
    let data = undefined;
    const getData = () => tslib_es6.__awaiter(this, void 0, void 0, function* () {
        if (data !== undefined) {
            return data;
        }
        return initPromise;
    });
    return {
        getData,
        setData: (newData) => {
            data = newData;
        },
        setDataInFn: (fn) => tslib_es6.__awaiter(this, void 0, void 0, function* () {
            const nowData = yield getData();
            data = fn(nowData);
        }),
    };
}

exports.hookAsyncData = hookAsyncData;
//# sourceMappingURL=hooks.js.map
