UNPKG

type-enforcer

Version:
24 lines (22 loc) 902 B
import enforceArray from '../../enforcer/types/enforceArray'; import { buildMethod, deepCompare, mapEnforcer, setDeepOnInit } from './methodAny'; /** * Builds a chainable method for getting/setting an array * * @function method.array * @extends method.any * * @arg {Object} [options] - Same as {@link method.any} with the following differences: * @arg {*} [options.init=[]] * @arg {Function} [options.enforce=enforce.array] * @arg {Function} [options.compare=deepCompare] - Performs a deep comparison between values with [lodash.isEqual]{@link https://lodash.com/docs/#isEqual} * @arg {Boolean} [options.deep=true] - If false then only use strict equality * @arg {Boolean} [options.coerce=false] - If true then coerce the value when possible * * @returns {Function} */ export default buildMethod({ enforce: mapEnforcer(enforceArray), init: [], compare: deepCompare }, setDeepOnInit);