UNPKG

rubico

Version:

[a]synchronous functional programming

8 lines (7 loc) 512 B
/** * rubico v2.6.2 * https://github.com/a-synchronous/rubico * (c) 2019-2024 Richard Tong * rubico may be freely distributed under the MIT license. */ const isString=function(r){return"string"==typeof r||null!=r&&r.constructor==String},isArray=Array.isArray,prepend=r=>function(n){if(isArray(n))return isArray(r)?[...r,...n]:[r,...n];if(isString(n)){if(!isString(r))throw new TypeError(`${r} is not a string`);return`${r}${n}`}throw new TypeError(`${n} is not an Array or string`)};export default prepend;