Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prototyped.js

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prototyped.js - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

18

CHANGELOG.md
# Changelog
## [v0.3.2](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.3.2) *(2018-01-25)*
**Implemented enhancements:**
- `Array.prototype`
- function `initial` added
- function `tail` added
- function `append` added
- `String.prototype`
- function `contains` added
## [v0.3.1](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.3.1) *(2018-01-24)*
**Implemented enhancements:**
- es6 usage is now available along side es5 (dist)
**Fixed bugs:**
- typescript usage
## [v0.3.0](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.3.0) *(2018-01-24)*

@@ -4,0 +22,0 @@ **Implemented enhancements:**

3

dist/array.d.ts

@@ -14,2 +14,4 @@ /**

last(): T;
initial(): Array<T>;
tail(): Array<T>;
chunk(size: number): Array<Array<T>>;

@@ -51,2 +53,3 @@ compact(): Array<T>;

pad(size: number, value?: any): Array<any>;
append(value?: any): void;
prepend(value?: any): void;

@@ -53,0 +56,0 @@ }

2

dist/array.js

@@ -1,1 +0,1 @@

"use strict";function r(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}Array.isInstance||(Array.isInstance=Array.isArray),Array.range||(Array.range=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Array.from({length:Math.ceil((r+1-t)/n)}).map(function(r,o){return o*n+t})}),Array.repeat||(Array.repeat=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Array(r).fill(t)}),Array.prototype.first||(Array.prototype.first=function(){return this[0]}),Array.prototype.last||(Array.prototype.last=function(){return this[this.length-1]}),Array.prototype.chunk||(Array.prototype.chunk=function(r){var t=this;return Array.from({length:Math.ceil(this.length/r)},function(n,o){return t.slice(o*r,o*r+r)})}),Array.prototype.compact||(Array.prototype.compact=function(){return this.filter(Boolean)}),Array.prototype.count||(Array.prototype.count=function(r){return r?this.reduce(function(t,n){return n===r?t+1:t+0},0):this.length}),Array.prototype.countBy||(Array.prototype.countBy=function(r){return this.map("function"==typeof r?r:function(t){return t[r]}).reduce(function(r,t,n){return r[t]=(r[t]||0)+1,r},{})}),Array.prototype.flatten||(Array.prototype.flatten=function(){return function r(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1!=n?t.reduce(function(t,o){return t.concat(Array.isArray(o)?r(o,n-1):o)},[]):t.reduce(function(r,t){return r.concat(t)},[])}(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:1)}),Array.prototype.deepFlatten||(Array.prototype.deepFlatten=function(){return function t(n){var o;return(o=[]).concat.apply(o,r(n.map(function(r){return Array.isArray(r)?t(r):r})))}(this)}),Array.prototype.diff||(Array.prototype.diff=function(r,t){if(t)return this.filter(function(n){return-1===r.findIndex(function(r){return t(n,r)})});var n=new Set(r);return this.filter(function(r){return!n.has(r)})}),Array.prototype.distinct||(Array.prototype.distinct=function(){return[].concat(r(new Set(this)))}),Array.prototype.everyNth||(Array.prototype.everyNth=function(r){return this.filter(function(t,n){return n%r==r-1})}),Array.prototype.groupBy||(Array.prototype.groupBy=function(r){var t=this;return this.map("function"==typeof r?r:function(t){return t[r]}).reduce(function(r,n,o){return r[n]=(r[n]||[]).concat(t[o]),r},{})}),Array.prototype.indexOfAll||(Array.prototype.indexOfAll=function(r){var t=[];return this.forEach(function(n,o){return n===r&&t.push(o)}),t}),Array.prototype.intersect||(Array.prototype.intersect=function(r){var t=new Set(r);return this.filter(function(r){return t.has(r)})}),Array.prototype.partition||(Array.prototype.partition=function(r){return this.reduce(function(t,n,o,e){return t[r(n,o,e)?0:1].push(n),t},[[],[]])}),Array.prototype.pull||(Array.prototype.pull=function(){for(var r=this,t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var e=Array.isArray(n[0])?n[0]:n,a=this.filter(function(r){return!e.includes(r)});this.length=0,a.forEach(function(t){return r.push(t)})}),Array.prototype.sample||(Array.prototype.sample=function(){return this[Math.floor(Math.random()*this.length)]}),Array.prototype.shuffle||(Array.prototype.shuffle=function(){return function(r){for(var t,n=(t=r,Array.isArray(t)?t:Array.from(t)).slice(0),o=n.length;o;){var e=Math.floor(Math.random()*o--),a=[n[e],n[o]];n[o]=a[0],n[e]=a[1]}return n}(this)}),Array.prototype.union||(Array.prototype.union=function(t){return Array.from(new Set([].concat(r(this),r(t))))}),Array.prototype.zip||(Array.prototype.zip=function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];n=[this].concat(r(n));var e=Math.max.apply(Math,r(n.map(function(r){return r.length})));return Array.from({length:e}).map(function(r,t){return Array.from({length:n.length},function(r,o){return n[o][t]})})}),Array.prototype.zipObject||(Array.prototype.zipObject=function(r){return this.reduce(function(t,n,o){return t[n]=r[o],t},{})}),Array.prototype.pluck||(Array.prototype.pluck=function(r){var t=r.split(".");return this.map(function(r){return t.map(function(t){return r=r&&r[t]||void 0}),r})}),Array.prototype.sum||(Array.prototype.sum=function(r){var t=0;if(r){var n=r.split(".");return this.map(function(r){n.map(function(t){return r=r&&r[t]||0}),t+=r}),t}return this.map(function(r){return t+=r}),t}),Array.prototype.average||(Array.prototype.average=function(r){return this.sum(r)/this.length}),Array.prototype.avg||(Array.prototype.avg=Array.prototype.average),Array.prototype.max||(Array.prototype.max=function(r){var t=-1/0;if(r){var n=r.split(".");return this.map(function(r){n.map(function(t){return r=r&&r[t]||0}),t=Math.max(r,t)}),t}return this.map(function(r){return t=Math.max(r,t)}),t}),Array.prototype.min||(Array.prototype.min=function(r){var t=1/0;if(r){var n=r.split(".");return this.map(function(r){n.map(function(t){return r=r&&r[t]||0}),t=Math.min(r,t)}),t}return this.map(function(r){return t=Math.min(r,t)}),t}),Array.prototype.contains||(Array.prototype.contains=function(r){return-1!==this.indexOf(r)}),Array.prototype.crossJoin||(Array.prototype.crossJoin=function(r){var t=[];return this.map(function(n){r.map(function(r){t.push([n,r])})}),t}),Array.prototype.get||(Array.prototype.get=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return r>=this.length?t:this[r]}),Array.prototype.implode||(Array.prototype.implode=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:", ",n=r.split("."),o=[];return this.map(function(r){n.map(function(t){return r=r&&r[t]||void 0}),o.push(r)}),o.compact().join(t)}),Array.prototype.clone||(Array.prototype.clone=function(){return[].concat(r(this))}),Array.prototype.median||(Array.prototype.median=function(r){var t=this;t.sort(function(r,t){return r-t});var n=Math.floor(t.length/2);if(r){var o=r.split(".");if(t.length%2){var e=t[n];return o.map(function(r){return e=e&&e[r]||e}),e}var a=t[n-1],i=t[n];return o.map(function(r){return a=a&&a[r]||a}),o.map(function(r){return i=i&&i[r]||i}),(a+i)/2}return t.length%2?t[n]:(t[n-1]+t[n])/2}),Array.prototype.pad||(Array.prototype.pad=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Math.abs(r);if(n<=this.length)return this;var o=Array.repeat(n-this.length,t);return r<0?o.concat(this):this.concat(o)}),Array.prototype.prepend||(Array.prototype.prepend=function(t){var n=this.clone();this.length=0,this.push.apply(this,r([t].concat(n)))});
"use strict";function r(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}Array.isInstance||(Array.isInstance=Array.isArray),Array.range||(Array.range=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Array.from({length:Math.ceil((r+1-t)/n)}).map(function(r,o){return o*n+t})}),Array.repeat||(Array.repeat=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Array(r).fill(t)}),Array.prototype.first||(Array.prototype.first=function(){return this[0]}),Array.prototype.last||(Array.prototype.last=function(){return this[this.length-1]}),Array.prototype.initial||(Array.prototype.initial=function(){return this.slice(0,-1)}),Array.prototype.tail||(Array.prototype.tail=function(){return this.length>1?this.slice(1):[]}),Array.prototype.chunk||(Array.prototype.chunk=function(r){var t=this;return Array.from({length:Math.ceil(this.length/r)},function(n,o){return t.slice(o*r,o*r+r)})}),Array.prototype.compact||(Array.prototype.compact=function(){return this.filter(Boolean)}),Array.prototype.count||(Array.prototype.count=function(r){return r?this.reduce(function(t,n){return n===r?t+1:t+0},0):this.length}),Array.prototype.countBy||(Array.prototype.countBy=function(r){return this.map("function"==typeof r?r:function(t){return t[r]}).reduce(function(r,t,n){return r[t]=(r[t]||0)+1,r},{})}),Array.prototype.flatten||(Array.prototype.flatten=function(){return function r(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1!=n?t.reduce(function(t,o){return t.concat(Array.isArray(o)?r(o,n-1):o)},[]):t.reduce(function(r,t){return r.concat(t)},[])}(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:1)}),Array.prototype.deepFlatten||(Array.prototype.deepFlatten=function(){return function t(n){var o;return(o=[]).concat.apply(o,r(n.map(function(r){return Array.isArray(r)?t(r):r})))}(this)}),Array.prototype.diff||(Array.prototype.diff=function(r,t){if(t)return this.filter(function(n){return-1===r.findIndex(function(r){return t(n,r)})});var n=new Set(r);return this.filter(function(r){return!n.has(r)})}),Array.prototype.distinct||(Array.prototype.distinct=function(){return[].concat(r(new Set(this)))}),Array.prototype.everyNth||(Array.prototype.everyNth=function(r){return this.filter(function(t,n){return n%r==r-1})}),Array.prototype.groupBy||(Array.prototype.groupBy=function(r){var t=this;return this.map("function"==typeof r?r:function(t){return t[r]}).reduce(function(r,n,o){return r[n]=(r[n]||[]).concat(t[o]),r},{})}),Array.prototype.indexOfAll||(Array.prototype.indexOfAll=function(r){var t=[];return this.forEach(function(n,o){return n===r&&t.push(o)}),t}),Array.prototype.intersect||(Array.prototype.intersect=function(r){var t=new Set(r);return this.filter(function(r){return t.has(r)})}),Array.prototype.partition||(Array.prototype.partition=function(r){return this.reduce(function(t,n,o,e){return t[r(n,o,e)?0:1].push(n),t},[[],[]])}),Array.prototype.pull||(Array.prototype.pull=function(){for(var r=this,t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var e=Array.isArray(n[0])?n[0]:n,a=this.filter(function(r){return!e.includes(r)});this.length=0,a.forEach(function(t){return r.push(t)})}),Array.prototype.sample||(Array.prototype.sample=function(){return this[Math.floor(Math.random()*this.length)]}),Array.prototype.shuffle||(Array.prototype.shuffle=function(){return function(r){for(var t,n=(t=r,Array.isArray(t)?t:Array.from(t)).slice(0),o=n.length;o;){var e=Math.floor(Math.random()*o--),a=[n[e],n[o]];n[o]=a[0],n[e]=a[1]}return n}(this)}),Array.prototype.union||(Array.prototype.union=function(t){return Array.from(new Set([].concat(r(this),r(t))))}),Array.prototype.zip||(Array.prototype.zip=function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];n=[this].concat(r(n));var e=Math.max.apply(Math,r(n.map(function(r){return r.length})));return Array.from({length:e}).map(function(r,t){return Array.from({length:n.length},function(r,o){return n[o][t]})})}),Array.prototype.zipObject||(Array.prototype.zipObject=function(r){return this.reduce(function(t,n,o){return t[n]=r[o],t},{})}),Array.prototype.pluck||(Array.prototype.pluck=function(r){var t=r.split(".");return this.map(function(r){return t.map(function(t){return r=r&&r[t]||void 0}),r})}),Array.prototype.sum||(Array.prototype.sum=function(r){var t=0;if(r){var n=r.split(".");return this.map(function(r){n.map(function(t){return r=r&&r[t]||0}),t+=r}),t}return this.map(function(r){return t+=r}),t}),Array.prototype.average||(Array.prototype.average=function(r){return this.sum(r)/this.length}),Array.prototype.avg||(Array.prototype.avg=Array.prototype.average),Array.prototype.max||(Array.prototype.max=function(r){var t=-1/0;if(r){var n=r.split(".");return this.map(function(r){n.map(function(t){return r=r&&r[t]||0}),t=Math.max(r,t)}),t}return this.map(function(r){return t=Math.max(r,t)}),t}),Array.prototype.min||(Array.prototype.min=function(r){var t=1/0;if(r){var n=r.split(".");return this.map(function(r){n.map(function(t){return r=r&&r[t]||0}),t=Math.min(r,t)}),t}return this.map(function(r){return t=Math.min(r,t)}),t}),Array.prototype.contains||(Array.prototype.contains=function(r){return-1!==this.indexOf(r)}),Array.prototype.crossJoin||(Array.prototype.crossJoin=function(r){var t=[];return this.map(function(n){r.map(function(r){t.push([n,r])})}),t}),Array.prototype.get||(Array.prototype.get=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return r>=this.length?t:this[r]}),Array.prototype.implode||(Array.prototype.implode=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:", ",n=r.split("."),o=[];return this.map(function(r){n.map(function(t){return r=r&&r[t]||void 0}),o.push(r)}),o.compact().join(t)}),Array.prototype.clone||(Array.prototype.clone=function(){return[].concat(r(this))}),Array.prototype.median||(Array.prototype.median=function(r){var t=this;t.sort(function(r,t){return r-t});var n=Math.floor(t.length/2);if(r){var o=r.split(".");if(t.length%2){var e=t[n];return o.map(function(r){return e=e&&e[r]||e}),e}var a=t[n-1],i=t[n];return o.map(function(r){return a=a&&a[r]||a}),o.map(function(r){return i=i&&i[r]||i}),(a+i)/2}return t.length%2?t[n]:(t[n-1]+t[n])/2}),Array.prototype.pad||(Array.prototype.pad=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Math.abs(r);if(n<=this.length)return this;var o=Array.repeat(n-this.length,t);return r<0?o.concat(this):this.concat(o)}),Array.prototype.append||(Array.prototype.append=function(t){var n=this.concat([t]);this.length=0,this.push.apply(this,r(n))}),Array.prototype.prepend||(Array.prototype.prepend=function(t){var n=this.clone();this.length=0,this.push.apply(this,r([t].concat(n)))});

@@ -21,4 +21,5 @@ /**

words(pattern?: RegExp): Array<string>;
contains(str: string): boolean;
}
}
export {};

@@ -1,1 +0,1 @@

"use strict";String.isInstance||(String.isInstance=function(t){return"string"==typeof t}),String.prototype.capitalize||(String.prototype.capitalize=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.replace(/\b[a-z]/g,function(t){return t.toUpperCase()}):this.replace(/^[a-z]/,function(t){return t.toUpperCase()})}),String.prototype.decapitalize||(String.prototype.decapitalize=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.replace(/\b[A-Z]/g,function(t){return t.toLowerCase()}):this.replace(/^[A-Z]/,function(t){return t.toLowerCase()})}),String.prototype.mask||(String.prototype.mask=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*";return this.slice(0,-t).replace(/./g,r)+this.slice(-t)}),String.prototype.pluralize||(String.prototype.pluralize=function(t,r){return r||(r=this+"s"),1===t?this:r}),String.prototype.reverse||(String.prototype.reverse=function(){return[].concat(function(t){if(Array.isArray(t)){for(var r=0,e=Array(t.length);r<t.length;r++)e[r]=t[r];return e}return Array.from(t)}(this)).reverse().join("")}),String.prototype.lines||(String.prototype.lines=function(){return this.split(/\r?\n/)}),String.prototype.camelCase||(String.prototype.camelCase=function(){var t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);t||(t=[""]);var r=t.map(function(t){return t.slice(0,1).toUpperCase()+t.slice(1).toLowerCase()}).join("");return r.slice(0,1).toLowerCase()+r.slice(1)}),String.prototype.kebabCase||(String.prototype.kebabCase=function(){var t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(function(t){return t.toLowerCase()}).join("-")}),String.prototype.snakeCase||(String.prototype.snakeCase=function(){var t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(function(t){return t.toLowerCase()}).join("_")}),String.prototype.truncate||(String.prototype.truncate=function(t){return this.length>t?this.slice(0,t>3?t-3:t)+"...":this}),String.prototype.words||(String.prototype.words=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:/[^a-zA-Z-]+/;return this.split(t).filter(Boolean)});
"use strict";String.isInstance||(String.isInstance=function(t){return"string"==typeof t}),String.prototype.capitalize||(String.prototype.capitalize=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.replace(/\b[a-z]/g,function(t){return t.toUpperCase()}):this.replace(/^[a-z]/,function(t){return t.toUpperCase()})}),String.prototype.decapitalize||(String.prototype.decapitalize=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.replace(/\b[A-Z]/g,function(t){return t.toLowerCase()}):this.replace(/^[A-Z]/,function(t){return t.toLowerCase()})}),String.prototype.mask||(String.prototype.mask=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*";return this.slice(0,-t).replace(/./g,r)+this.slice(-t)}),String.prototype.pluralize||(String.prototype.pluralize=function(t,r){return r||(r=this+"s"),1===t?this:r}),String.prototype.reverse||(String.prototype.reverse=function(){return[].concat(function(t){if(Array.isArray(t)){for(var r=0,e=Array(t.length);r<t.length;r++)e[r]=t[r];return e}return Array.from(t)}(this)).reverse().join("")}),String.prototype.lines||(String.prototype.lines=function(){return this.split(/\r?\n/)}),String.prototype.camelCase||(String.prototype.camelCase=function(){var t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);t||(t=[""]);var r=t.map(function(t){return t.slice(0,1).toUpperCase()+t.slice(1).toLowerCase()}).join("");return r.slice(0,1).toLowerCase()+r.slice(1)}),String.prototype.kebabCase||(String.prototype.kebabCase=function(){var t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(function(t){return t.toLowerCase()}).join("-")}),String.prototype.snakeCase||(String.prototype.snakeCase=function(){var t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(function(t){return t.toLowerCase()}).join("_")}),String.prototype.truncate||(String.prototype.truncate=function(t){return this.length>t?this.slice(0,t>3?t-3:t)+"...":this}),String.prototype.words||(String.prototype.words=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:/[^a-zA-Z-]+/;return this.split(t).filter(Boolean)}),String.prototype.contains||(String.prototype.contains=function(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?-1!==this.indexOf(t):-1!==this.toLowerCase().indexOf(t.toLowerCase())});

@@ -14,2 +14,4 @@ /**

last(): T;
initial(): Array<T>;
tail(): Array<T>;
chunk(size: number): Array<Array<T>>;

@@ -51,2 +53,3 @@ compact(): Array<T>;

pad(size: number, value?: any): Array<any>;
append(value?: any): void;
prepend(value?: any): void;

@@ -53,0 +56,0 @@ }

@@ -1,1 +0,1 @@

"use strict";Array.isInstance||(Array.isInstance=Array.isArray),Array.range||(Array.range=((t,r=0,e=1)=>Array.from({length:Math.ceil((t+1-r)/e)}).map((t,o)=>o*e+r))),Array.repeat||(Array.repeat=((t,r=0)=>Array(t).fill(r))),Array.prototype.first||(Array.prototype.first=function(){return this[0]}),Array.prototype.last||(Array.prototype.last=function(){return this[this.length-1]}),Array.prototype.chunk||(Array.prototype.chunk=function(t){return Array.from({length:Math.ceil(this.length/t)},(r,e)=>this.slice(e*t,e*t+t))}),Array.prototype.compact||(Array.prototype.compact=function(){return this.filter(Boolean)}),Array.prototype.count||(Array.prototype.count=function(t){return t?this.reduce((r,e)=>e===t?r+1:r+0,0):this.length}),Array.prototype.countBy||(Array.prototype.countBy=function(t){return this.map("function"==typeof t?t:r=>r[t]).reduce((t,r,e)=>(t[r]=(t[r]||0)+1,t),{})}),Array.prototype.flatten||(Array.prototype.flatten=function(t=1){const r=(t,e=1)=>1!=e?t.reduce((t,o)=>t.concat(Array.isArray(o)?r(o,e-1):o),[]):t.reduce((t,r)=>t.concat(r),[]);return r(this,t)}),Array.prototype.deepFlatten||(Array.prototype.deepFlatten=function(){const t=r=>[].concat(...r.map(r=>Array.isArray(r)?t(r):r));return t(this)}),Array.prototype.diff||(Array.prototype.diff=function(t,r){if(r)return this.filter(e=>-1===t.findIndex(t=>r(e,t)));const e=new Set(t);return this.filter(t=>!e.has(t))}),Array.prototype.distinct||(Array.prototype.distinct=function(){return[...new Set(this)]}),Array.prototype.everyNth||(Array.prototype.everyNth=function(t){return this.filter((r,e)=>e%t==t-1)}),Array.prototype.groupBy||(Array.prototype.groupBy=function(t){return this.map("function"==typeof t?t:r=>r[t]).reduce((t,r,e)=>(t[r]=(t[r]||[]).concat(this[e]),t),{})}),Array.prototype.indexOfAll||(Array.prototype.indexOfAll=function(t){let r=[];return this.forEach((e,o)=>e===t&&r.push(o)),r}),Array.prototype.intersect||(Array.prototype.intersect=function(t){const r=new Set(t);return this.filter(t=>r.has(t))}),Array.prototype.partition||(Array.prototype.partition=function(t){return this.reduce((r,e,o,p)=>(r[t(e,o,p)?0:1].push(e),r),[[],[]])}),Array.prototype.pull||(Array.prototype.pull=function(...t){let r=Array.isArray(t[0])?t[0]:t,e=this.filter(t=>!r.includes(t));this.length=0,e.forEach(t=>this.push(t))}),Array.prototype.sample||(Array.prototype.sample=function(){return this[Math.floor(Math.random()*this.length)]}),Array.prototype.shuffle||(Array.prototype.shuffle=function(){return(([...t])=>{let r=t.length;for(;r;){const e=Math.floor(Math.random()*r--);[t[r],t[e]]=[t[e],t[r]]}return t})(this)}),Array.prototype.union||(Array.prototype.union=function(t){return Array.from(new Set([...this,...t]))}),Array.prototype.zip||(Array.prototype.zip=function(...t){t=[this,...t];const r=Math.max(...t.map(t=>t.length));return Array.from({length:r}).map((r,e)=>Array.from({length:t.length},(r,o)=>t[o][e]))}),Array.prototype.zipObject||(Array.prototype.zipObject=function(t){return this.reduce((r,e,o)=>(r[e]=t[o],r),{})}),Array.prototype.pluck||(Array.prototype.pluck=function(t){let r=t.split(".");return this.map(t=>(r.map(r=>t=t&&t[r]||void 0),t))}),Array.prototype.sum||(Array.prototype.sum=function(t){let r=0;if(t){let e=t.split(".");return this.map(t=>{e.map(r=>t=t&&t[r]||0),r+=t}),r}return this.map(t=>r+=t),r}),Array.prototype.average||(Array.prototype.average=function(t){return this.sum(t)/this.length}),Array.prototype.avg||(Array.prototype.avg=Array.prototype.average),Array.prototype.max||(Array.prototype.max=function(t){let r=-1/0;if(t){let e=t.split(".");return this.map(t=>{e.map(r=>t=t&&t[r]||0),r=Math.max(t,r)}),r}return this.map(t=>r=Math.max(t,r)),r}),Array.prototype.min||(Array.prototype.min=function(t){let r=1/0;if(t){let e=t.split(".");return this.map(t=>{e.map(r=>t=t&&t[r]||0),r=Math.min(t,r)}),r}return this.map(t=>r=Math.min(t,r)),r}),Array.prototype.contains||(Array.prototype.contains=function(t){return-1!==this.indexOf(t)}),Array.prototype.crossJoin||(Array.prototype.crossJoin=function(t){let r=[];return this.map(e=>{t.map(t=>{r.push([e,t])})}),r}),Array.prototype.get||(Array.prototype.get=function(t,r){return t>=this.length?r:this[t]}),Array.prototype.implode||(Array.prototype.implode=function(t,r=", "){let e=t.split("."),o=[];return this.map(t=>{e.map(r=>t=t&&t[r]||void 0),o.push(t)}),o.compact().join(r)}),Array.prototype.clone||(Array.prototype.clone=function(){return[...this]}),Array.prototype.median||(Array.prototype.median=function(t){let r=this;r.sort((t,r)=>t-r);let e=Math.floor(r.length/2);if(t){let o=t.split(".");if(r.length%2){let t=r[e];return o.map(r=>t=t&&t[r]||t),t}let p=r[e-1],n=r[e];return o.map(t=>p=p&&p[t]||p),o.map(t=>n=n&&n[t]||n),(p+n)/2}return r.length%2?r[e]:(r[e-1]+r[e])/2}),Array.prototype.pad||(Array.prototype.pad=function(t,r=0){let e=Math.abs(t);if(e<=this.length)return this;let o=Array.repeat(e-this.length,r);return t<0?o.concat(this):this.concat(o)}),Array.prototype.prepend||(Array.prototype.prepend=function(t){let r=this.clone();this.length=0,this.push(...[t].concat(r))});
"use strict";Array.isInstance||(Array.isInstance=Array.isArray),Array.range||(Array.range=((t,r=0,e=1)=>Array.from({length:Math.ceil((t+1-r)/e)}).map((t,o)=>o*e+r))),Array.repeat||(Array.repeat=((t,r=0)=>Array(t).fill(r))),Array.prototype.first||(Array.prototype.first=function(){return this[0]}),Array.prototype.last||(Array.prototype.last=function(){return this[this.length-1]}),Array.prototype.initial||(Array.prototype.initial=function(){return this.slice(0,-1)}),Array.prototype.tail||(Array.prototype.tail=function(){return this.length>1?this.slice(1):[]}),Array.prototype.chunk||(Array.prototype.chunk=function(t){return Array.from({length:Math.ceil(this.length/t)},(r,e)=>this.slice(e*t,e*t+t))}),Array.prototype.compact||(Array.prototype.compact=function(){return this.filter(Boolean)}),Array.prototype.count||(Array.prototype.count=function(t){return t?this.reduce((r,e)=>e===t?r+1:r+0,0):this.length}),Array.prototype.countBy||(Array.prototype.countBy=function(t){return this.map("function"==typeof t?t:r=>r[t]).reduce((t,r,e)=>(t[r]=(t[r]||0)+1,t),{})}),Array.prototype.flatten||(Array.prototype.flatten=function(t=1){const r=(t,e=1)=>1!=e?t.reduce((t,o)=>t.concat(Array.isArray(o)?r(o,e-1):o),[]):t.reduce((t,r)=>t.concat(r),[]);return r(this,t)}),Array.prototype.deepFlatten||(Array.prototype.deepFlatten=function(){const t=r=>[].concat(...r.map(r=>Array.isArray(r)?t(r):r));return t(this)}),Array.prototype.diff||(Array.prototype.diff=function(t,r){if(r)return this.filter(e=>-1===t.findIndex(t=>r(e,t)));const e=new Set(t);return this.filter(t=>!e.has(t))}),Array.prototype.distinct||(Array.prototype.distinct=function(){return[...new Set(this)]}),Array.prototype.everyNth||(Array.prototype.everyNth=function(t){return this.filter((r,e)=>e%t==t-1)}),Array.prototype.groupBy||(Array.prototype.groupBy=function(t){return this.map("function"==typeof t?t:r=>r[t]).reduce((t,r,e)=>(t[r]=(t[r]||[]).concat(this[e]),t),{})}),Array.prototype.indexOfAll||(Array.prototype.indexOfAll=function(t){let r=[];return this.forEach((e,o)=>e===t&&r.push(o)),r}),Array.prototype.intersect||(Array.prototype.intersect=function(t){const r=new Set(t);return this.filter(t=>r.has(t))}),Array.prototype.partition||(Array.prototype.partition=function(t){return this.reduce((r,e,o,p)=>(r[t(e,o,p)?0:1].push(e),r),[[],[]])}),Array.prototype.pull||(Array.prototype.pull=function(...t){let r=Array.isArray(t[0])?t[0]:t,e=this.filter(t=>!r.includes(t));this.length=0,e.forEach(t=>this.push(t))}),Array.prototype.sample||(Array.prototype.sample=function(){return this[Math.floor(Math.random()*this.length)]}),Array.prototype.shuffle||(Array.prototype.shuffle=function(){return(([...t])=>{let r=t.length;for(;r;){const e=Math.floor(Math.random()*r--);[t[r],t[e]]=[t[e],t[r]]}return t})(this)}),Array.prototype.union||(Array.prototype.union=function(t){return Array.from(new Set([...this,...t]))}),Array.prototype.zip||(Array.prototype.zip=function(...t){t=[this,...t];const r=Math.max(...t.map(t=>t.length));return Array.from({length:r}).map((r,e)=>Array.from({length:t.length},(r,o)=>t[o][e]))}),Array.prototype.zipObject||(Array.prototype.zipObject=function(t){return this.reduce((r,e,o)=>(r[e]=t[o],r),{})}),Array.prototype.pluck||(Array.prototype.pluck=function(t){let r=t.split(".");return this.map(t=>(r.map(r=>t=t&&t[r]||void 0),t))}),Array.prototype.sum||(Array.prototype.sum=function(t){let r=0;if(t){let e=t.split(".");return this.map(t=>{e.map(r=>t=t&&t[r]||0),r+=t}),r}return this.map(t=>r+=t),r}),Array.prototype.average||(Array.prototype.average=function(t){return this.sum(t)/this.length}),Array.prototype.avg||(Array.prototype.avg=Array.prototype.average),Array.prototype.max||(Array.prototype.max=function(t){let r=-1/0;if(t){let e=t.split(".");return this.map(t=>{e.map(r=>t=t&&t[r]||0),r=Math.max(t,r)}),r}return this.map(t=>r=Math.max(t,r)),r}),Array.prototype.min||(Array.prototype.min=function(t){let r=1/0;if(t){let e=t.split(".");return this.map(t=>{e.map(r=>t=t&&t[r]||0),r=Math.min(t,r)}),r}return this.map(t=>r=Math.min(t,r)),r}),Array.prototype.contains||(Array.prototype.contains=function(t){return-1!==this.indexOf(t)}),Array.prototype.crossJoin||(Array.prototype.crossJoin=function(t){let r=[];return this.map(e=>{t.map(t=>{r.push([e,t])})}),r}),Array.prototype.get||(Array.prototype.get=function(t,r){return t>=this.length?r:this[t]}),Array.prototype.implode||(Array.prototype.implode=function(t,r=", "){let e=t.split("."),o=[];return this.map(t=>{e.map(r=>t=t&&t[r]||void 0),o.push(t)}),o.compact().join(r)}),Array.prototype.clone||(Array.prototype.clone=function(){return[...this]}),Array.prototype.median||(Array.prototype.median=function(t){let r=this;r.sort((t,r)=>t-r);let e=Math.floor(r.length/2);if(t){let o=t.split(".");if(r.length%2){let t=r[e];return o.map(r=>t=t&&t[r]||t),t}let p=r[e-1],n=r[e];return o.map(t=>p=p&&p[t]||p),o.map(t=>n=n&&n[t]||n),(p+n)/2}return r.length%2?r[e]:(r[e-1]+r[e])/2}),Array.prototype.pad||(Array.prototype.pad=function(t,r=0){let e=Math.abs(t);if(e<=this.length)return this;let o=Array.repeat(e-this.length,r);return t<0?o.concat(this):this.concat(o)}),Array.prototype.append||(Array.prototype.append=function(t){let r=this.concat([t]);this.length=0,this.push(...r)}),Array.prototype.prepend||(Array.prototype.prepend=function(t){let r=this.clone();this.length=0,this.push(...[t].concat(r))});

@@ -21,4 +21,5 @@ /**

words(pattern?: RegExp): Array<string>;
contains(str: string): boolean;
}
}
export {};

@@ -1,1 +0,1 @@

"use strict";String.isInstance||(String.isInstance=(t=>"string"==typeof t)),String.prototype.capitalize||(String.prototype.capitalize=function(t=!1){return t?this.replace(/\b[a-z]/g,t=>t.toUpperCase()):this.replace(/^[a-z]/,t=>t.toUpperCase())}),String.prototype.decapitalize||(String.prototype.decapitalize=function(t=!1){return t?this.replace(/\b[A-Z]/g,t=>t.toLowerCase()):this.replace(/^[A-Z]/,t=>t.toLowerCase())}),String.prototype.mask||(String.prototype.mask=function(t=4,e="*"){return this.slice(0,-t).replace(/./g,e)+this.slice(-t)}),String.prototype.pluralize||(String.prototype.pluralize=function(t,e){return e||(e=`${this}s`),1===t?this:e}),String.prototype.reverse||(String.prototype.reverse=function(){return[...this].reverse().join("")}),String.prototype.lines||(String.prototype.lines=function(){return this.split(/\r?\n/)}),String.prototype.camelCase||(String.prototype.camelCase=function(){let t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);t||(t=[""]);let e=t.map(t=>t.slice(0,1).toUpperCase()+t.slice(1).toLowerCase()).join("");return e.slice(0,1).toLowerCase()+e.slice(1)}),String.prototype.kebabCase||(String.prototype.kebabCase=function(){let t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(t=>t.toLowerCase()).join("-")}),String.prototype.snakeCase||(String.prototype.snakeCase=function(){let t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(t=>t.toLowerCase()).join("_")}),String.prototype.truncate||(String.prototype.truncate=function(t){return this.length>t?this.slice(0,t>3?t-3:t)+"...":this}),String.prototype.words||(String.prototype.words=function(t=/[^a-zA-Z-]+/){return this.split(t).filter(Boolean)});
"use strict";String.isInstance||(String.isInstance=(t=>"string"==typeof t)),String.prototype.capitalize||(String.prototype.capitalize=function(t=!1){return t?this.replace(/\b[a-z]/g,t=>t.toUpperCase()):this.replace(/^[a-z]/,t=>t.toUpperCase())}),String.prototype.decapitalize||(String.prototype.decapitalize=function(t=!1){return t?this.replace(/\b[A-Z]/g,t=>t.toLowerCase()):this.replace(/^[A-Z]/,t=>t.toLowerCase())}),String.prototype.mask||(String.prototype.mask=function(t=4,e="*"){return this.slice(0,-t).replace(/./g,e)+this.slice(-t)}),String.prototype.pluralize||(String.prototype.pluralize=function(t,e){return e||(e=`${this}s`),1===t?this:e}),String.prototype.reverse||(String.prototype.reverse=function(){return[...this].reverse().join("")}),String.prototype.lines||(String.prototype.lines=function(){return this.split(/\r?\n/)}),String.prototype.camelCase||(String.prototype.camelCase=function(){let t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);t||(t=[""]);let e=t.map(t=>t.slice(0,1).toUpperCase()+t.slice(1).toLowerCase()).join("");return e.slice(0,1).toLowerCase()+e.slice(1)}),String.prototype.kebabCase||(String.prototype.kebabCase=function(){let t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(t=>t.toLowerCase()).join("-")}),String.prototype.snakeCase||(String.prototype.snakeCase=function(){let t=this.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);return t||(t=[""]),t.map(t=>t.toLowerCase()).join("_")}),String.prototype.truncate||(String.prototype.truncate=function(t){return this.length>t?this.slice(0,t>3?t-3:t)+"...":this}),String.prototype.words||(String.prototype.words=function(t=/[^a-zA-Z-]+/){return this.split(t).filter(Boolean)}),String.prototype.contains||(String.prototype.contains=function(t,e=!1){return e?-1!==this.indexOf(t):-1!==this.toLowerCase().indexOf(t.toLowerCase())});
{
"name": "prototyped.js",
"version": "0.3.1",
"version": "0.3.2",
"description": "Some common typescript ready prototypes available in both es6 and es5",

@@ -27,2 +27,4 @@ "author": "Ardalan Amini <ardalanamini22@gmail.com>",

"last",
"initial",
"tail",
"chunk",

@@ -59,2 +61,3 @@ "compact",

"pad",
"append",
"prepend",

@@ -68,2 +71,13 @@ "boolean",

"string",
"capitalize",
"decapitalize",
"mask",
"pluralize",
"reverse",
"lines",
"camelCase",
"kebabCase",
"snakeCase",
"truncate",
"words",
"math",

@@ -70,0 +84,0 @@ "factorial",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc