UNPKG

dreamstate

Version:

Store management library based on react context and observers

75 lines (73 loc) 2.46 kB
/** * Utility function to check whether the supplied parameter is a string. * * @param {unknown} target The parameter to check. * @returns {boolean} True if the parameter is a string, otherwise false. */ function isString(target) { return typeof target === "string"; } /** * Utility function to check whether the supplied parameter is a number primitive. * * @param {unknown} target The parameter to check. * @returns {boolean} True if the parameter is a number, otherwise false. */ function isNumber(target) { return typeof target === "number"; } /** * Utility function to check whether the supplied parameter is an object. * * @param {unknown} target The parameter to check. * @returns {boolean} True if the parameter is an object, otherwise false. */ function isObject(target) { return typeof target === "object" && target !== null; } /** * Utility function to check whether the supplied parameter is a symbol. * * @param {unknown} target The parameter to check. * @returns {boolean} True if the parameter is a symbol, otherwise false. */ function isSymbol(target) { return typeof target === "symbol"; } /** * Utility function to check whether the supplied parameter is a function. * * @param {unknown} target The parameter to check. * @returns {boolean} True if the parameter is a function, otherwise false. */ function isFunction(target) { return typeof target === "function"; } /** * Utility function to check whether the supplied parameter is undefined. * * @param {unknown} target The parameter to check. * @returns {boolean} True if the parameter is undefined, otherwise false. */ function isUndefined(target) { return typeof target === "undefined"; } /** * Check whether the provided type is correct for query usage. * * @param {unknown} type The provided type to check. * @returns {boolean} True if the provided type is valid for query usage, otherwise false. */ function isCorrectQueryType(type) { return isString(type) || isNumber(type) || isSymbol(type); } /** * Check whether the provided type is correct for signal usage. * * @param {unknown} type The provided type to check. * @returns {boolean} True if the provided type is valid for signal usage, otherwise false. */ function isCorrectSignalType(type) { return isString(type) || isNumber(type) || isSymbol(type); } export { isCorrectQueryType, isCorrectSignalType, isFunction, isNumber, isObject, isString, isSymbol, isUndefined };