Sha256: 7ec0c2da1ae90d4557091fc3f004638e5cffaffddd316962e25ba2f10ca8ac7f

Contents?: true

Size: 944 Bytes

Versions: 84

Compression:

Stored size: 944 Bytes

Contents

/**
 * Copy all properties from `props` onto `obj`.
 * @param {object} obj Object onto which properties should be copied.
 * @param {object} props Object from which to copy properties.
 * @returns {object}
 * @private
 */
export function extend(obj, props) {
	for (let i in props) obj[i] = props[i];
	return obj;
}

/** Invoke or update a ref, depending on whether it is a function or object ref.
 *  @param {object|function} [ref=null]
 *  @param {any} [value]
 */
export function applyRef(ref, value) {
	if (ref!=null) {
		if (typeof ref=='function') ref(value);
		else ref.current = value;
	}
}

/**
 * Call a function asynchronously, as soon as possible. Makes
 * use of HTML Promise to schedule the callback if available,
 * otherwise falling back to `setTimeout` (mainly for IE<11).
 * @type {(callback: function) => void}
 */
export const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
govuk_publishing_components-17.20.0 node_modules/preact/src/util.js
govuk_publishing_components-17.19.1 node_modules/preact/src/util.js
govuk_publishing_components-17.19.0 node_modules/preact/src/util.js
govuk_publishing_components-17.18.0 node_modules/preact/src/util.js
govuk_publishing_components-17.17.0 node_modules/preact/src/util.js
govuk_publishing_components-17.16.0 node_modules/preact/src/util.js
govuk_publishing_components-17.15.0 node_modules/preact/src/util.js
govuk_publishing_components-17.14.0 node_modules/preact/src/util.js
govuk_publishing_components-17.13.0 node_modules/preact/src/util.js
govuk_publishing_components-17.12.2 node_modules/preact/src/util.js
govuk_publishing_components-17.12.1 node_modules/preact/src/util.js
govuk_publishing_components-17.12.0 node_modules/preact/src/util.js
govuk_publishing_components-17.11.0 node_modules/preact/src/util.js
govuk_publishing_components-17.10.0 node_modules/preact/src/util.js
govuk_publishing_components-17.9.0 node_modules/preact/src/util.js
govuk_publishing_components-17.8.0 node_modules/preact/src/util.js
govuk_publishing_components-17.7.0 node_modules/preact/src/util.js
govuk_publishing_components-17.6.1 node_modules/preact/src/util.js
govuk_publishing_components-17.6.0 node_modules/preact/src/util.js
govuk_publishing_components-17.5.0 node_modules/preact/src/util.js