-
Notifications
You must be signed in to change notification settings - Fork 3
/
spellbook.js
1 lines (1 loc) · 19.4 KB
/
spellbook.js
1
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sb=n():t.sb=n()}(self,(function(){return t={49:(t,n,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}var e=r(829),a=r(737);t.exports={shuffle:function(t){if(e.isArray(t))return Object.assign([],t).sort((function(t,n){return.5-Math.random()}));throw new Error("Shuffle function not contains array.")},first:function(t){if(e.isArray(t))return t[0];throw new Error("first function not contains array.")},last:function(t){if(e.isArray(t))return t[t.length-1];throw new Error("Last function not contains array.")},remove:function(t,n){var r=a.assign(t),i=function(t,n){return t.filter((function(t){if(JSON.stringify(t)!==JSON.stringify(n))return t}))};return e.isArray(n)?(n.forEach((function(t){return r=i(r,t)})),r):i(r,n)},clear:function(t){var n=a.assign(t);if(e.isArray(n))return n.splice(n.length,0);throw new Error("clear function not contains array.")},inArray:function(t,n){if(e.isArray(t))return!!~t.indexOf(n);throw new Error("inArray function not contains array.")},uniqBy:function(t,n){if(e.isArray(t)){for(var r=[],i={},a=0;a<t.length;a++)void 0===i[t[a][n]]&&void 0!==t[a][n]&&(r.push(t[a][n]),i[t[a][n]]=1);return r}throw new Error("uniq function not contains array.")},uniq:function(t){for(var n=[],r=function(t,n){for(var r=0;r<t.length;r++)if(JSON.stringify(t[r])===JSON.stringify(n))return!0;return!1},i=0;i<t.length;i++)r(n,t[i])||n.push(t[i]);return n},filter:function(t,n){if(e.isEmpty(t))throw new Error("filter function not contains array.");if(e.isEmpty(n)||!e.isFunction(n))throw new Error("Find in array need a function.");return t.filter(n)},filterBy:function(t,n){if(e.isEmpty(t))throw new Error("filter function not contains array.");if(e.isEmpty(n)&&"object"!==i(n))throw new Error("Find in array need a object.");var r=Object.keys(n);return t.filter((function(t){var i=!0;return r.forEach((function(r){"string"==typeof t[r]?t[r].indexOf(n[r])<0&&(i=!1):t[r]!==n[r]&&(i=!1)})),i}))},map:function(t,n){if(e.isArray(t)){if(e.isFunction(n))return t.map(n);throw new Error("map function not contains callback function.")}throw new Error("map function not contains array.")},reduce:function(t,n){if(e.isArray(t)){if(e.isFunction(n))return t.reduce(n);throw new Error("map function not contains callback function.")}throw new Error("reduce function not contains array.")},forEach:function(t,n){if(e.isArray(t))throw e.isFunction(n)&&t.forEach(n),new Error("forEach function not contains callback function.");throw new Error("forEach function not contains array.")},sort:function(t,n){if(e.isArray(t))return e.isFunction(n)?t.sort(n):t.sort();throw new Error("sort function not contains array.")},chunk:function(t,n){for(var r=[],i=0;i<t.length;i+=n)r.push(t.slice(i,i+n));return r}}},836:t=>{t.exports={isTrue:function(t){return!0===t},isFalse:function(t){return!1===t},isEqual:function(t,n){return JSON.stringify(t)===JSON.stringify(n)},not:function(t){return!1===t},and:function(t,n){return!(!t||!n)}}},299:(t,n,r)=>{function i(t,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var e=r(829),a=r(499),o=r(850),s=r(49),u=r(737),c=r(962),f=r(168),h=r(836),l=r(520);t.exports=function(){function t(n){if(function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),e.isEmpty(n))throw new Error("Chain function not contains values.");this.data=n}var n,r;return n=t,(r=[{key:"ifElse",value:function(t,n){return this.data=o.ifElse(this.data,t,n),this}},{key:"function",value:function(t){return this.data=o.function(this.data,t),this}},{key:"toInt",value:function(){return this.data=c.toInt(this.data),this}},{key:"excerpt",value:function(){return this.data=c.excerpt(this.data),this}},{key:"dos2unix",value:function(){return this.data=c.dos2unix(this.data),this}},{key:"capitalize",value:function(){return this.data=c.capitalize(this.data),this}},{key:"toJSON",value:function(){return this.data=c.toJSON(this.data),this}},{key:"json",value:function(){return this.data=c.json(this.data),this}},{key:"split",value:function(t,n){return this.data=c.split(this.data,t,n),this}},{key:"toLowerCase",value:function(){return this.data=c.toLowerCase(this.data),this}},{key:"toUpperCase",value:function(){return this.data=c.toUpperCase(this.data),this}},{key:"trim",value:function(){return this.data=c.trim(this.data),this}},{key:"replace",value:function(t,n){return this.data=c.replace(this.data,t,n),this}},{key:"pad",value:function(t,n){return this.data=c.pad(this.data,t,n),this}},{key:"duplicate",value:function(){return this.data=f.duplicate(this.data),this}},{key:"min",value:function(){return this.data=f.min(this.data),this}},{key:"max",value:function(){return this.data=f.max(this.data),this}},{key:"sum",value:function(t){return this.data=f.sum(this.data,t),this}},{key:"mult",value:function(t){return this.data=f.mult(this.data,t),this}},{key:"divide",value:function(t){return this.data=f.divide(this.data,t),this}},{key:"numerator",value:function(t){return this.data=f.divide(t,this.data),this}},{key:"ceil",value:function(){return this.data=f.ceil(this.data),this}},{key:"round",value:function(){return this.data=f.round(this.data),this}},{key:"floor",value:function(){return this.data=f.floor(this.data),this}},{key:"trunc",value:function(){return this.data=f.trunc(this.data),this}},{key:"toString",value:function(){return this.data=l.toString(this.data),this}},{key:"size",value:function(){return this.data=l.size(this.data),this}},{key:"contains",value:function(t){return this.data=l.contains(this.data,t),this}},{key:"reverse",value:function(){return this.data=l.reverse(this.data),this}},{key:"repeatify",value:function(t){return this.data=l.repeatify(this.data,t),this}},{key:"concat",value:function(t){return this.data=l.concat(this.data,t),this}},{key:"isFunction",value:function(){return this.data=e.isFunction(this.data),this}},{key:"isArray",value:function(){return this.data=e.isArray(this.data),this}},{key:"isObject",value:function(){return this.data=e.isObject(this.data),this}},{key:"isNumber",value:function(){return this.data=e.isNumber(this.data),this}},{key:"isString",value:function(){return this.data=e.isString(this.data),this}},{key:"isBoolean",value:function(){return this.data=e.isBoolean(this.data),this}},{key:"isInteger",value:function(){return this.data=e.isInteger(this.data),this}},{key:"isEmpty",value:function(){return this.data=e.isEmpty(this.data),this}},{key:"isSet",value:function(){return this.data=e.isSet(this.data),this}},{key:"empty",value:function(){return this.data=e.isEmpty(this.data),this}},{key:"isNull",value:function(){return this.data=e.isNull(this.data),this}},{key:"isNaN",value:function(){return this.data=e.isNaN(this.data),this}},{key:"isUndefined",value:function(){return this.data=e.isUndefined(this.data),this}},{key:"shuffle",value:function(){return this.data=s.shuffle(this.data),this}},{key:"first",value:function(){return this.data=s.first(this.data),this}},{key:"last",value:function(){return this.data=s.last(this.data),this}},{key:"remove",value:function(t){return this.data=s.remove(this.data,t),this}},{key:"clear",value:function(){return this.data=s.clear(this.data),this}},{key:"inArray",value:function(t){return this.data=s.inArray(this.data,t),this}},{key:"unq",value:function(){return this.data=s.uniq(this.data),this}},{key:"uniq",value:function(){return this.data=s.uniq(this.data),this}},{key:"uniqBy",value:function(t){return this.data=s.uniq(this.data,t),this}},{key:"filter",value:function(t){return this.data=s.filter(this.data,t),this}},{key:"filterBy",value:function(t){return this.data=s.filterBy(this.data,t),this}},{key:"map",value:function(t){return this.data=s.map(this.data,t),this}},{key:"reduce",value:function(t){return this.data=s.reduce(this.data,t),this}},{key:"sort",value:function(t){return this.data=s.sort(this.data,t),this}},{key:"chunk",value:function(t){return this.data=s.chunk(this.data,t),this}},{key:"forEach",value:function(t){s.forEach(this.data,t)}},{key:"extend",value:function(t){return this.data=u.extend(this.data,t),this}},{key:"get",value:function(t){return this.data=u.get(this.data,t),this}},{key:"keys",value:function(){return this.data=u.keys(this.data),this}},{key:"getKeys",value:function(){return this.data=u.getKeys(this.data),this}},{key:"merge",value:function(t){return this.data=u.merge(this.data,t),this}},{key:"isTrue",value:function(){return this.data=h.isTrue(this.data),this}},{key:"isFalse",value:function(){return this.data=h.isFalse(this.data),this}},{key:"isEqual",value:function(t){return this.data=h.isEqual(this.data,t),this}},{key:"eq",value:function(t){return this.data=h.isEqual(this.data,t),this}},{key:"Not",value:function(){return this.data=h.not(this.data),this}},{key:"not",value:function(){return this.data=h.not(this.data),this}},{key:"and",value:function(t){return!!this.data&&(this.data=t,this)}},{key:"on",value:function(t,n){return a.on(t,n),this}},{key:"emit",value:function(t){return a.emit(t,this.data),this}},{key:"delete",value:function(t){return a.delete(t),this}},{key:"r",value:function(){return this.data}},{key:"return",value:function(){return this.data}},{key:"v",value:function(){return this.data}},{key:"value",value:function(){return this.data}},{key:"end",value:function(){return null}},{key:"noReturn",value:function(){return null}}])&&i(n.prototype,r),t}()},520:(t,n,r)=>{var i=r(829);t.exports={toString:function(t){if(i.isEmpty(t))throw new Error("toString function not contains value to parse.");return JSON.stringify(t)},size:function(t){if(i.isEmpty(t))throw new Error("size function not contains values.");if(i.isArray(t)||i.isString(t))return t.length;if(i.isObject(t))return Object.keys(t).length;throw new Error("size function not contains compatible values.")},contains:function(t,n){if(i.isArray(t)||i.isString(t))return!!~t.indexOf(n);if(i.isObject(t))return!!~Object.keys(t).indexOf(n);throw new Error("contains function not contains values.")},reverse:function(t){if(i.isArray(t))return t.reverse();if(i.isString(t))return t.split("").reverse().join("");throw new Error("Reverse function not contains array or string.")},repeatify:function(t,n){if(i.isEmpty(t))throw new Error("repeatify function not have data for repeat.");if(i.isEmpty(n)||!i.isNumber(n))throw new Error("repeatify function not have a number for repeat.");for(var r=[],e=0;e<n;e++)r.push(t);return r},concat:function(t,n){if(i.isEmpty(t)||i.isEmpty(n))throw new Error("concat function not have values.");if(i.isString(t)&&i.isString(t))return t+n;if(i.isArray(t)&&i.isArray(t))return t.concat(n);throw new Error("concat function not contains same values.")},return:function(t){return t}}},880:(t,n,r)=>{var i=r(829),e=r(499),a=r(850),o=r(49),s=r(737),u=r(962),c=r(168),f=r(836),h=r(520),l=r(299);t.exports={range:a.range,random:a.random,ifElse:a.ifElse,function:a.function,toInt:u.toInt,excerpt:u.excerpt,capitalize:u.capitalize,toJSON:u.toJSON,json:u.json,dos2unix:u.dos2unix,split:u.split,toUpperCase:u.toUpperCase,toLowerCase:u.toLowerCase,trim:u.trim,replace:u.replace,pad:u.pad,duplicate:c.duplicate,sum:c.sum,min:c.min,max:c.max,divide:c.divide,mult:c.mult,ceil:c.ceil,round:c.round,floor:c.floor,trunc:c.trunc,toString:h.toString,size:h.size,contains:h.contains,reverse:h.reverse,repeatify:h.repeatify,concat:h.concat,return:h.return,isFunction:i.isFunction,isArray:i.isArray,isObject:i.isObject,isNumber:i.isNumber,isString:i.isString,isBoolean:i.isBoolean,isInteger:i.isInteger,isEmpty:i.isEmpty,isSet:i.isSet,empty:i.isEmpty,isNull:i.isNull,isNaN:i.isNaN,isUndefined:i.isUndefined,e:function(t,n){return i.isEmpty(s.get(t,n))},shuffle:o.shuffle,first:o.first,last:o.last,remove:o.remove,clear:o.clear,inArray:o.inArray,unq:o.uniq,uniq:o.uniq,uniqBy:o.uniqBy,filter:o.filter,filterBy:o.filterBy,map:o.map,reduce:o.reduce,sort:o.sort,forEach:o.forEach,chunk:o.chunk,extend:s.extend,assign:s.assign,clone:s.assign,get:s.get,keys:s.keys,getKeys:s.getKeys,merge:s.merge,isTrue:f.isTrue,isFalse:f.isFalse,isEqual:f.isEqual,eq:f.isEqual,Not:f.Not,on:e.on,emit:e.emit,delete:e.delete,chain:function(t){return new l(t)},c:function(t){return new l(t)}}},168:(t,n,r)=>{var i=r(829);t.exports={duplicate:function(t){if(i.isNumber(t))return 2*t;throw new Error("Duplicate function needs a number.")},min:function(t){if(i.isArray(t)){var n=!0;if(t.forEach((function(t){n&&!i.isNumber(t)&&(n=!1)})),n)return Math.min.apply(Math,t);throw new Error("Min funciton needs an array of numbers.")}throw new Error("Min funciton needs an array.")},max:function(t){if(i.isArray(t)){var n=!0;if(t.forEach((function(t){n&&!i.isNumber(t)&&(n=!1)})),n)return Math.max.apply(Math,t);throw new Error("Min funciton needs an array of numbers.")}throw new Error("Min funciton needs an array.")},sum:function(t,n){if(i.isNumber(t)&&i.isNumber(n))return t+n;throw new Error("Sum function only can operate with numbers.")},divide:function(t,n){if(i.isNumber(t)&&i.isNumber(n))return t/n;throw new Error("Divide function only can operate with numbers.")},mult:function(t,n){if(i.isNumber(t)&&i.isNumber(n))return n*t;throw new Error("Mult function only can operate with numbers.")},ceil:function(t){if(i.isNumber(t))return Math.ceil(t);throw new Error("ceil function only can operate with numbers.")},round:function(t){if(i.isNumber(t))return Math.round(t);throw new Error("round function only can operate with numbers.")},floor:function(t){if(i.isNumber(t))return Math.floor(t);throw new Error("floor function only can operate with numbers.")},trunc:function(t){if(i.isNumber(t))return Math.trunc(t);throw new Error("floor function only can operate with numbers.")}}},737:(t,n,r)=>{var i=r(829);t.exports={extend:function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);return t},assign:function(t){if(i.isNull(t)||!i.isObject(t)||"isActiveClone"in t)return t;var n=t.constructor();for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t.isActiveClone=null,n[r]=t[r],delete t.isActiveClone);return n},get:function(t,n){if(!i.isEmpty(t)&&i.isString(n)){if(1===(n=n.split(".")).length)return t[n[0]];for(var r=0;r<n.length;r++){if(i.isEmpty(t[n[r]]))return;t=t[n[r]]}return t}},keys:function(t){return Object.keys(t)},getKeys:function(t,n){var r={};return i.isArray(n)?n.forEach((function(n){r[n]=t[n]})):r[n]=t[n],r},merge:function(t,n){var r={};if(i.isObject(t)&&i.isObject(n))return Object.keys(t).forEach((function(n){r[n]=t[n]})),Object.keys(n).forEach((function(t){r[t]=n[t]})),r;throw new Error("Merge option need two objects for work")}}},962:(t,n,r)=>{var i=r(829);t.exports={toInt:function(t){if(i.isEmpty(t))throw new Error("To int needs an string value.");if(i.isString(t))return parseInt(t,10);throw new Error("toInt function has incompatible value.")},dos2unix:function(t){if(i.isEmpty(t))throw new Error("Dos2unix function needs an string value.");if(i.isString(t))return t.replace(/\r\n/g,"\n");throw new Error("Dos2unix function has incompatible value.")},capitalize:function(t){if(i.isEmpty(t))throw new Error("Capitalize function needs an string value.");if(i.isString(t))return t.slice(0,1).toUpperCase()+t.slice(1);throw new Error("Capitalize function has incompatible value.")},excerpt:function(t,n){var r=t.split(" ");return r.splice(n,r.length-1),r.join(" ")},toJSON:function(t){if(i.isEmpty(t))throw new Error("toJSON function needs an string value.");if(i.isString(t))return JSON.parse(t);throw new Error("toJSON function has incompatible value.")},json:function(t){if(i.isEmpty(t))throw new Error("toJSON function needs an string value.");if(i.isString(t))return JSON.parse(t);throw new Error("toJSON function has incompatible value.")},split:function(t,n,r){if(i.isEmpty(t))throw new Error("Split function needs an string value.");if(i.isString(t))return t.split(n,r);throw new Error("Split function has incompatible value.")},toLowerCase:function(t){if(i.isEmpty(t))throw new Error("toLowerCase function needs an string value.");if(i.isString(t))return t.toLowerCase();throw new Error("toLowerCase function has incompatible value.")},toUpperCase:function(t){if(i.isEmpty(t))throw new Error("toUpperCase function needs an string value.");if(i.isString(t))return t.toUpperCase();throw new Error("toUpperCase function has incompatible value.")},trim:function(t){if(i.isEmpty(t))throw new Error("trim function needs an string value.");if(i.isString(t))return t.trim();throw new Error("trim function has incompatible value.")},replace:function(t,n,r){if(i.isEmpty(t)&&i.isEmpty(r))throw new Error("replace function needs an string value.");if(i.isString(t)&&i.isString(r))return t.replace(n,r);throw new Error("replace function has incompatible value.")},pad:function(t,n,r){return n>>=0,r=String(r||" "),t.length>n?String(t):((n-=t.length)>r.length&&(r+=r.repeat(n/r.length)),r.slice(0,n)+String(t))}}},850:(t,n,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}var e=r(829);t.exports={range:function(t,n,r){var a=[];if(e.isEmpty(t)||e.isEmpty(n))return[];if(i(t)!==i(n))return[];if(e.isNumber(t))for(a[0]=t,r=r||1;t+r<=n;)a[a.length]=t+=r;else{var o="abcdefghijklmnopqrstuvwxyz";t===t.toUpperCase()&&(n=n.toUpperCase(),o=o.toUpperCase()),a=(o=o.substring(o.indexOf(t),o.indexOf(n)+1)).split("")}return a},random:function(t,n){return e.isNumber(t)&&e.isNumber(n)?Math.floor(Math.random()*(n-t))+t:e.isArray(t)?t[Math.floor(Math.random()*t.length)]:0},ifElse:function(t,n,r){return t?n():r()},function:function(t,n){return n(t)}}},499:function(t,n,r){const i=r(829),e={event_stack:{},on:(t,n)=>{if(i.isEmpty(this.event_stack)&&(this.event_stack={}),i.isEmpty(t))throw new Error("Need event key!");if(!i.isFunction(n))throw new Error("Event needs a function!");if(i.isArray(t))for(let r=0;r<t.length;r++)this.event_stack[t[r]]=n;else this.event_stack[t]=n},emit:(t,n)=>{if(i.isEmpty(t))throw new Error("No event selected.");if(i.isArray(t))for(let r=0;r<t.length;r++)i.isFunction(this.event_stack[t[r]])&&this.event_stack[t[r]](n);else i.isFunction(this.event_stack[t])&&this.event_stack[t](n)},delete:t=>{i.isSet(this.event_stack[t])&&delete this.event_stack[t]}};"object"==typeof process&&(t.exports=e)},829:t=>{var n={isFunction:function(t){return"function"==typeof t},isArray:function(t){return"object"==typeof t&&t instanceof Array},isObject:function(t){return"object"==typeof t&&!(t instanceof Array)&&null!==t},isNumber:function(t){return"number"==typeof t||t instanceof Number},isInteger:function(t){return!!n.isNumber(t)&&t%1==0},isString:function(t){return"string"==typeof t||t instanceof String},isBoolean:function(t){return"boolean"==typeof t},isEmpty:function(t){return n.isUndefined(t)||n.isNull(t)||""===t},isNull:function(t){return null===t},isNaN:function(t){return isNaN(t)},isUndefined:function(t){return void 0===t},isSet:function(t){return!n.isEmpty(t)},get:function(t,r){if(n.isSet(t)&&n.isSet(r)){if(1===(r=r.split(".")).length)return t[r[0]];for(var i=0;i<r.length;i++){if(!n.isSet(t[r[i]]))return;t=t[r[i]]}return t}}};n.f=n.isFunction,n.a=n.isArray,n.o=n.isObject,n.n=n.isNumber,n.i=n.isInteger,n.s=n.isString,n.b=n.isBoolean,n.e=n.isEmpty,n.null=n.isNull,n.nan=n.isNaN,n.u=n.isUndefined,n.set=n.isSet,n.g=n.get,t.exports=n}},n={},function r(i){var e=n[i];if(void 0!==e)return e.exports;var a=n[i]={exports:{}};return t[i].call(a.exports,a,a.exports,r),a.exports}(880);var t,n}));