UNPKG

rubico

Version:

[a]synchronous functional programming

9 lines (8 loc) 511 B
/** * Rubico v2.8.2 * https://rubico.land/ * * © Richard Yufei Tong, King of Software * Rubico may be freely distributed under the CFOSS 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;