UNPKG

apply-ref

Version:
46 lines (36 loc) 1.02 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var apply = function apply(ref, value) { if (_typeof(ref) === "object" && ref !== null) { // @ts-ignore ref.current = value; } if (typeof ref === "function") { ref(value); } }; var applyRefs = function applyRefs() { for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { refs[_key] = arguments[_key]; } return function (value) { refs.forEach(function (ref) { return apply(ref, value); }); }; }; exports.applyRefs = applyRefs; exports.default = apply;