Socket
Socket
Sign inDemoInstall

protoblast

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protoblast - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

lib/request_browser.js

13

CHANGELOG.md

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

## 0.6.2 (2018-11-09)
* Add State class
* Add `RURL#seems_valid` property
* Rewrite `Request` class & add browser support
* `Function#throttle(fnc)` now accepts a config object as second argument
* `Function#throttle(fnc, config)` can now be used in classes
* Add `throttle` method decorator
* Add `Blast.requestIdleCallback` implementation
* Removed japanese & hebrew `romanize` string methods
* Removed `Function.curry` function
* Upgrade json-dry dependency to 1.0.8
## 0.6.1 (2018-10-16)

@@ -2,0 +15,0 @@

52

lib/array.js

@@ -14,3 +14,3 @@ module.exports = function BlastArray(Blast, Collection, Bound, Obj) {

*/
Blast.defineStatic('Array', 'likeArray', function likeArray(variable) {
Blast.defineStatic('Array', function likeArray(variable) {

@@ -46,3 +46,3 @@ // Return the variable unmodified if it's already an array

*/
Blast.defineStatic('Array', 'cast', function cast(variable) {
Blast.defineStatic('Array', function cast(variable) {

@@ -93,3 +93,3 @@ var type;

*/
Blast.defineStatic('Array', 'range', function range(start, stop, step) {
Blast.defineStatic('Array', function range(start, stop, step) {

@@ -144,3 +144,3 @@ var result = [],

*/
Blast.definePrototype('Array', 'fill', function fill(value, start, end) {
Blast.definePrototype('Array', function fill(value, start, end) {

@@ -195,3 +195,3 @@ var length = this.length,

*/
Blast.definePrototype('Array', 'move', function move(oldIndex, newIndex) {
Blast.definePrototype('Array', function move(oldIndex, newIndex) {

@@ -242,3 +242,3 @@ var length = this.length,

*/
Blast.definePrototype('Array', 'first', function first(nr, page) {
Blast.definePrototype('Array', function first(nr, page) {

@@ -271,3 +271,3 @@ if (typeof nr === 'number') {

*/
Blast.definePrototype('Array', 'last', function last(nr, page) {
Blast.definePrototype('Array', function last(nr, page) {

@@ -303,3 +303,3 @@ if (typeof nr === 'number') {

*/
Blast.definePrototype('Array', 'sum', function sum(property, map) {
Blast.definePrototype('Array', function sum(property, map) {

@@ -386,3 +386,3 @@ var sumResult,

*/
Blast.definePrototype('Array', 'clip', function clip(lowest, highest) {
Blast.definePrototype('Array', function clip(lowest, highest) {

@@ -427,3 +427,3 @@ var length = this.length,

*/
Blast.definePrototype('Array', 'closest', function closest(goal) {
Blast.definePrototype('Array', function closest(goal) {

@@ -453,3 +453,3 @@ var closestVal = null,

*/
Blast.definePrototype('Array', 'max', function max(path) {
Blast.definePrototype('Array', function max(path) {

@@ -474,3 +474,3 @@ if (path) {

*/
Blast.definePrototype('Array', 'min', function min(path) {
Blast.definePrototype('Array', function min(path) {

@@ -497,3 +497,3 @@ if (path) {

*/
Blast.definePrototype('Array', 'insert', function insert(index, value) {
Blast.definePrototype('Array', function insert(index, value) {

@@ -530,3 +530,3 @@ var args,

*/
Blast.definePrototype('Array', 'include', function include(_index, values) {
Blast.definePrototype('Array', function include(_index, values) {

@@ -579,3 +579,3 @@ var allValues,

*/
Blast.definePrototype('Array', 'flatten', function flatten(limit) {
Blast.definePrototype('Array', function flatten(limit) {

@@ -621,3 +621,3 @@ var result,

*/
Blast.definePrototype('Array', 'unique', function unique(path) {
Blast.definePrototype('Array', function unique(path) {

@@ -666,3 +666,3 @@ var result = [],

*/
Blast.definePrototype('Array', 'shared', function shared(arr, cast_function) {
Blast.definePrototype('Array', function shared(arr, cast_function) {

@@ -709,3 +709,3 @@ // Make sure the given value to match against is an array

*/
Blast.definePrototype('Array', 'subtract', function subtract(arr, cast_function) {
Blast.definePrototype('Array', function subtract(arr, cast_function) {

@@ -755,3 +755,3 @@ // Make sure the given value to match against is an array

*/
Blast.definePrototype('Array', 'exclusive', function exclusive(arr, cast_function) {
Blast.definePrototype('Array', function exclusive(arr, cast_function) {

@@ -774,3 +774,3 @@ // Get all the shared values

*/
Blast.definePrototype('Array', 'clean', function clean(delete_value) {
Blast.definePrototype('Array', function clean(delete_value) {
for (var i = 0; i < this.length; i++) {

@@ -798,3 +798,3 @@ if (this[i] === delete_value) {

*/
Blast.definePrototype('Array', 'sortByPath', function sortByPath(_order, _paths) {
Blast.definePrototype('Array', function sortByPath(_order, _paths) {

@@ -863,3 +863,3 @@ var paths,

*/
Blast.definePrototype('Array', 'findByPath', function findByPath(path, value) {
Blast.definePrototype('Array', function findByPath(path, value) {

@@ -936,3 +936,3 @@ var entries,

*/
Blast.definePrototype('Array', 'modifyByPath', function modifyByPath(path, fnc) {
Blast.definePrototype('Array', function modifyByPath(path, fnc) {

@@ -983,3 +983,3 @@ var pieces,

*/
Blast.definePrototype('Array', 'shuffle', function shuffle(rng) {
Blast.definePrototype('Array', function shuffle(rng) {

@@ -1021,3 +1021,3 @@ var counter = this.length,

*/
Blast.definePrototype('Array', 'createIterator', function createIterator() {
Blast.definePrototype('Array', function createIterator() {
return new Blast.Classes.Iterator(this);

@@ -1037,3 +1037,3 @@ });

*/
Blast.definePrototype('Array', 'after', function after(needle) {
Blast.definePrototype('Array', function after(needle) {

@@ -1040,0 +1040,0 @@ var index = this.indexOf(needle);

@@ -55,3 +55,3 @@ /**

*/
Blast.definePrototype('Date', 'format', function format(pattern) {
Blast.definePrototype('Date', function format(pattern) {
var date = this;

@@ -58,0 +58,0 @@

@@ -70,3 +70,3 @@ module.exports = function BlastDate(Blast, Collection, Bound, Obj) {

*/
Blast.defineStatic('Date', 'create', function create(value) {
Blast.defineStatic('Date', function create(value) {
if (value == null) {

@@ -86,3 +86,3 @@ return new Date();

*/
Blast.defineStatic('Date', 'isDate', function isDate(variable) {
Blast.defineStatic('Date', function isDate(variable) {
return Object.prototype.toString.call(variable) === '[object Date]';

@@ -102,3 +102,3 @@ });

*/
Blast.defineStatic('Date', 'getUnitMs', function getUnitMs(unit) {
Blast.defineStatic('Date', function getUnitMs(unit) {

@@ -128,3 +128,3 @@ var result = ms_units[unit];

*/
Blast.defineStatic('Date', 'difference', function difference(unit, start, end, startOfUnit) {
Blast.defineStatic('Date', function difference(unit, start, end, startOfUnit) {

@@ -191,3 +191,3 @@ var diff;

*/
Blast.defineStatic('Date', 'parseString', function parseString(str, base) {
Blast.defineStatic('Date', function parseString(str, base) {
return new Date(Blast.Bound.Date.parseStringToTime(str, base));

@@ -208,3 +208,3 @@ });

*/
Blast.defineStatic('Date', 'parseStringToTime', function parseStringToTime(str, base) {
Blast.defineStatic('Date', function parseStringToTime(str, base) {

@@ -309,3 +309,3 @@ var unit_time,

*/
Blast.defineStatic('Date', 'parseDuration', function parseDuration(str, base) {
Blast.defineStatic('Date', function parseDuration(str, base) {
return Blast.Bound.Date.parseStringToTime(str, 0);

@@ -336,3 +336,3 @@ });

*/
Blast.definePrototype('Date', 'clone', function clone() {
Blast.definePrototype('Date', function clone() {
return new Date(this.valueOf());

@@ -350,3 +350,3 @@ });

*/
Blast.definePrototype('Date', 'stripTime', function stripTime() {
Blast.definePrototype('Date', function stripTime() {
return new Date(Date.UTC(this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate()));

@@ -365,3 +365,3 @@ });

*/
Blast.definePrototype('Date', 'stripDate', function stripDate() {
Blast.definePrototype('Date', function stripDate() {
return new Date(1970, 0, 1, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds());

@@ -379,3 +379,3 @@ });

*/
Blast.definePrototype('Date', 'setTimestring', function setTimestring(string) {
Blast.definePrototype('Date', function setTimestring(string) {

@@ -415,3 +415,3 @@ var pieces = string.split(':');

*/
Blast.definePrototype('Date', 'add', function add(amount, unit) {
Blast.definePrototype('Date', function add(amount, unit) {

@@ -462,3 +462,3 @@ var temp,

*/
Blast.definePrototype('Date', 'subtract', function subtract(amount, unit) {
Blast.definePrototype('Date', function subtract(amount, unit) {

@@ -497,3 +497,3 @@ var temp,

*/
Blast.definePrototype('Date', 'next', function next(unit) {
Blast.definePrototype('Date', function next(unit) {
return lastNext(this, +1, unit);

@@ -513,3 +513,3 @@ });

*/
Blast.definePrototype('Date', 'previous', function previous(unit) {
Blast.definePrototype('Date', function previous(unit) {
return lastNext(this, -1, unit);

@@ -644,3 +644,3 @@ });

*/
Blast.definePrototype('Date', 'startOf', function startOf(unit) {
Blast.definePrototype('Date', function startOf(unit) {

@@ -693,3 +693,3 @@ var temp;

*/
Blast.definePrototype('Date', 'endOf', function endOf(unit) {
Blast.definePrototype('Date', function endOf(unit) {

@@ -721,3 +721,3 @@ // Add one unit

*/
Blast.definePrototype('Date', 'between', function between(unit, start, end) {
Blast.definePrototype('Date', function between(unit, start, end) {

@@ -786,3 +786,3 @@ if (typeof unit != 'string' && unit != null) {

*/
Blast.definePrototype('Date', 'timeAgo', function timeAgo(settings) {
Blast.definePrototype('Date', function timeAgo(settings) {

@@ -789,0 +789,0 @@ var difference = Date.now() - this,

@@ -6,7 +6,3 @@ module.exports = function BlastDiacritics(Blast, Collection, Bound) {

diacriticsMap = {},
japaneseList,
japaneseMap,
diacritics,
hebrewList,
sortList,
base,

@@ -16,9 +12,2 @@ i;

/**
* A sort function for language map arrays
*/
sortList = function sortList(a, b) {
return b.original.length - a.original.length;
}
/**
* A map of all letters and their possible accented counterparts

@@ -119,217 +108,2 @@ *

/**
* A map of all japanese hiragana characters
*
* @author SirCmpwn
* @link https://github.com/SirCmpwn/hiragana.js
*/
japaneseMap = {
'a': 'あ',
'i': 'い',
'u': 'う',
'e': 'え',
'o': 'お',
'ka': 'か',
'ki': 'き',
'ku': 'く',
'ke': 'け',
'ko': 'こ',
'sa': 'さ',
'shi': 'し',
'su': 'す',
'se': 'せ',
'so': 'そ',
'ta': 'た',
'chi': 'ち',
'tsu': 'つ',
'te': 'て',
'to': 'と',
'na': 'な',
'ni': 'に',
'nu': 'ぬ',
'ne': 'ね',
'no': 'の',
'ha': 'は',
'hi': 'ひ',
'fu': 'ふ',
'he': 'へ',
'ho': 'ほ',
'ma': 'ま',
'mi': 'み',
'mu': 'む',
'me': 'め',
'mo': 'も',
'ya': 'や',
'yu': 'ゆ',
'yo': 'よ',
'ra': 'ら',
'ri': 'り',
'ru': 'る',
're': 'れ',
'ro': 'ろ',
'wa': 'わ',
'wo': 'を',
'ga': 'が',
'gi': 'ぎ',
'gu': 'ぐ',
'ge': 'げ',
'go': 'ご',
'za': 'ざ',
'ji': 'じ',
'zu': 'ず',
'ze': 'ぜ',
'zo': 'ぞ',
'da': 'だ',
'de': 'で',
'do': 'ど',
'ba': 'ば',
'bi': 'び',
'bu': 'ぶ',
'be': 'べ',
'bo': 'ぼ',
'pa': 'ぱ',
'pi': 'ぴ',
'pu': 'ぷ',
'pe': 'ぺ',
'po': 'ぽ',
'hu': 'ふ',
'tu': 'つ',
'si': 'し',
'ti': 'ち',
'kya': 'きゃ',
'kyu': 'きゅ',
'kyo': 'きょ',
'sha': 'しゃ',
'shu': 'しゅ',
'sho': 'しょ',
'cha': 'ちゃ',
'chu': 'ちゅ',
'cho': 'ちょ',
'nya': 'にゃ',
'nyu': 'にゅ',
'nyo': 'にょ',
'hya': 'ひゃ',
'hyu': 'ひゅ',
'hyo': 'ひょ',
'mya': 'みゃ',
'myu': 'みゅ',
'myo': 'みょ',
'rya': 'りゃ',
'ryu': 'りゅ',
'ryo': 'りょ',
'gya': 'ぎゃ',
'gyu': 'ぎゅ',
'gyo': 'ぎょ',
'ja': 'じゃ',
'ju': 'じゅ',
'jo': 'じょ',
'bya': 'びゃ',
'byu': 'びゅ',
'byo': 'びょ',
'pya': 'ぴゃ',
'pyu': 'ぴゅ',
'pyo': 'ぴょ',
'xyu': 'ゅ',
'xyo': 'ょ',
'xya': 'ゃ',
'xtsu': 'っ',
'xtu': 'っ',
'xa': 'ぁ',
'xi': 'ぃ',
'xu': 'ぅ',
'xe': 'ぇ',
'xo': 'ぉ',
'lyu': 'ゅ',
'lyo': 'ょ',
'lya': 'ゃ',
'ltsu': 'っ',
'ltu': 'っ',
'la': 'ぁ',
'li': 'ぃ',
'lu': 'ぅ',
'le': 'ぇ',
'lo': 'ぉ',
'rr': 'っr',
'tt': 'っt',
'kk': 'っk',
'cc': 'っc',
'pp': 'っp',
'ss': 'っs',
'ww': 'っw',
'ss': 'っy',
'dd': 'っd',
'ff': 'っf',
'gg': 'っg',
'hh': 'っh',
'jj': 'っj',
'zz': 'っz',
'xx': 'っx',
'vv': 'っv',
'bb': 'っb',
'mm': 'っm',
'nn': 'ん'
};
var hebrewMap = {
// Consonants
'\'' : ['\u05D0', '\u05E2'],
'v' : ['\u05D1', '\u05D5', '\u05D5\u05BC'],
'b' : '\u05D1\u05BC',
'g' : ['\u05D2', '\u05D2\u05BC'],
'j' : '\u05D2\u05F3',
'd' : ['\u05D3', '\u05D3\u05BC'],
'dh' : '\u05D3\u05F3',
'h' : ['\u05D4', '\u05D4\u05BC'],
'z' : ['\u05D6', '\u05D6\u05BC'],
'zh' : '\u05D6\u05F3',
'\u1E96' : '\u05D7',
't' : ['\u05D8', '\u05D8\u05BC'],
'y' : ['\u05D9', '\u05D9\u05BC'],
'kh' : ['\u05DA', '\u05DB'],
'k' : ['\u05DA\u05BC', '\u05DB\u05BC'],
'l' : ['\u05DC', '\u05DC\u05BC'],
'm' : ['\u05DD', '\u05DE', '\u05DE\u05BC'],
'n' : ['\u05DF', '\u05E0', '\u05E0\u05BC'],
's' : ['\u05E1', '\u05E1\u05BC', '\u05E9\u05C2', '\u05E9\u05BC\u05C2'],
'f' : ['\u05E3', '\u05E4'],
'p' : ['\u05E3\u05BC', '\u05E4\u05BC'],
'ts' : ['\u05E5', '\u05E6', '\u05E6\u05BC'],
'tsh' : ['\u05E5\u05F3', '\u05E6\u05F3'],
'k' : ['\u05E7', '\u05E7\u05BC'],
'r' : ['\u05E8', '\u05E8\u05BC'],
'sh' : ['\u05E9\u05C1', '\u05E9\u05BC\u05C1'],
't' : ['\u05EA', '\u05EA\u05BC'],
'th' : '\u05EA\u05F3',
// Vowels
'e' : ['\u05D8\u05B0', '\u05D7\u05B1', '\u05D8\u05B5', '\u05D8\u05B5\u05D9', '\u05D8\u05B6', '\u05D8\u05B6\u05D9'],
'a' : ['\u05D7\u05B2', '\u05D8\u05B7'],
'o' : ['\u05D7\u05B3', '\u05D8\u05B8', '\u05D8\u05B9'],
'i' : '\u05D8\u05B4',
'u' : ['\u05D8\u05BB', '\u05D8\u05D5\u05BC'],
// Israeli Diphthongs
'ay' : ['\u05D8\u05B7\u05D9', '\u05D8\u05B7\u05D9\u05B0', '\u05D8\u05B8\u05D9', '\u05D8\u05B8\u05D9\u05B0'],
'oy' : ['\u05D8\u05B9\u05D9', '\u05D8\u05B9\u05D9\u05B0'],
'uy' : ['\u05D8\u05BB\u05D9', '\u05D8\u05BB\u05D9\u05B0', '\u05D8\u05D5\u05BC\u05D9', '\u05D8\u05D5\u05BC\u05D9\u05B0']
};
hebrewList = [];
// Convert the hebrew map to an ordered list
for (base in hebrewMap) {
if (Array.isArray(hebrewMap[base])) {
for (i = 0; i < hebrewMap[base].length; i++) {
hebrewList.push({roman: base, original: hebrewMap[base][i]});
}
} else {
hebrewList.push({roman: base, original: hebrewMap[base]});
}
}
// Sort the hebrewlist
hebrewList.sort(sortList);
japaneseList = [];
for (base in baseDiacriticsMap) {

@@ -346,10 +120,2 @@

// Convert the japanese map to an ordered list
for (base in japaneseMap) {
japaneseList.push({roman: base, original: japaneseMap[base]});
}
// Sort the japaneselist
japaneseList.sort(sortList);
/**

@@ -370,3 +136,3 @@ * A regex for finding all combining marks

*/
Blast.definePrototype('String', 'removeCombiningMarks', function removeCombiningMarks() {
Blast.definePrototype('String', function removeCombiningMarks() {
return this.replace(allCombiningMarks, '');

@@ -380,17 +146,11 @@ });

* @since 0.0.1
* @version 0.1.0
* @version 0.6.2
*/
Blast.definePrototype('String', 'romanize', function romanize() {
Blast.definePrototype('String', function romanize() {
var length,
result = '',
str,
result = '',
str = this,
i;
// Romanize possible japanese signs
str = Bound.String.romanizeJapanese(this);
// Romanize possible hebrew signs
str = Bound.String.romanizeHebrew(str);
// Remove any other combining marks

@@ -409,72 +169,2 @@ str = Bound.String.removeCombiningMarks(str);

/**
* Turn japanese characters into their romanized forms
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.1.0
* @version 0.1.0
*
* @param {Boolean} skipCheck Don't check for characters first
*/
Blast.definePrototype('String', 'romanizeJapanese', function romanizeJapanese(skipCheck) {
var str,
entry,
i;
// Don't do anything if the string doesn't actually contain hebrew marks
if (!skipCheck && !Bound.String.containsJapanese(this)) {
return this;
}
str = this;
for (i = 0; i < japaneseList.length; i++) {
entry = japaneseList[i];
if (!entry.regex) {
entry.regex = new RegExp(entry.original, 'g');
}
str = str.replace(entry.regex, entry.roman);
}
return str;
});
/**
* Turn hebrew characters into their romanized forms
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.1.0
* @version 0.1.0
*
* @param {Boolean} skipCheck Don't check for characters first
*/
Blast.definePrototype('String', 'romanizeHebrew', function romanizeHebrew(skipCheck) {
var str,
entry,
i;
// Don't do anything if the string doesn't actually contain hebrew marks
if (!skipCheck && !Bound.String.containsHebrew(this)) {
return this;
}
str = this;
for (i = 0; i < hebrewList.length; i++) {
entry = hebrewList[i];
if (!entry.regex) {
entry.regex = new RegExp(entry.original, 'g');
}
str = str.replace(entry.regex, entry.roman);
}
return str;
});
/**
* Replace the given character, but remain case sensitive

@@ -529,3 +219,3 @@ *

*/
Blast.definePrototype('String', 'containsHebrew', function containsHebrew() {
Blast.definePrototype('String', function containsHebrew() {
return (this.search(hebrewRegex) > -1);

@@ -543,3 +233,3 @@ });

*/
Blast.definePrototype('String', 'containsJapanese', function containsJapanese() {
Blast.definePrototype('String', function containsJapanese() {
return (this.search(japaneseRegex) > -1);

@@ -560,3 +250,3 @@ });

*/
Blast.definePrototype('String', 'diacriticPattern', function diacriticPattern(insensitive, any) {
Blast.definePrototype('String', function diacriticPattern(insensitive, any) {

@@ -614,3 +304,3 @@ var replacer,

*/
Blast.definePrototype('String', 'diacriticRegex', function diacriticRegex(insensitive, any) {
Blast.definePrototype('String', function diacriticRegex(insensitive, any) {

@@ -617,0 +307,0 @@ var pattern = Bound.String.diacriticPattern(this, insensitive, any),

@@ -12,3 +12,3 @@ module.exports = function BlastError(Blast, Collection) {

*/
Blast.defineStatic('Error', 'unDry', function unDry(obj) {
Blast.defineStatic('Error', function unDry(obj) {

@@ -31,3 +31,3 @@ var result = new Error(obj.message);

*/
Blast.definePrototype('Error', 'toDry', function toDry() {
Blast.definePrototype('Error', function toDry() {
return {

@@ -34,0 +34,0 @@ value: {

@@ -116,2 +116,40 @@ module.exports = function BlastDecorators(Blast, Collection) {

/**
* Method throttler
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @param {Object|Number} config Config object or timeout in ms
*/
Blast.Decorators.throttle = function throttle(config) {
if (typeof config == 'number') {
config = {
minimum_wait : config
};
} else if (!config) {
config = {};
}
config.minimum_wait = config.minimum_wait || 5;
config.immediate = config.immediate || false;
config.reset_on_call = config.reset_on_call || false;
if (config.method == null) {
config.method = true;
}
return function throttler(options) {
var descriptor = options.descriptor;
// Overwrite the value
descriptor.value = Collection.Function.throttle(descriptor.value, config);
return options;
};
};
};

@@ -36,3 +36,3 @@ module.exports = function BlastFunctionFlow(Blast, Collection, Bound) {

}
Blast.defineStatic('Function', 'thrower', thrower);
Blast.defineStatic('Function', thrower);

@@ -52,3 +52,3 @@ /**

*/
Blast.defineStatic('Function', 'timebomb', function timebomb(timer, callback) {
Blast.defineStatic('Function', function timebomb(timer, callback) {

@@ -105,3 +105,3 @@ var bomb;

*/
Blast.defineStatic('Function', 'series', function series(_forceAsync, _tasks, _callback) {
Blast.defineStatic('Function', function series(_forceAsync, _tasks, _callback) {

@@ -305,3 +305,3 @@ var forceAsync,

*/
Blast.defineStatic('Function', 'parallel', function parallel(_forceAsync, _limit, _tasks, _callback) {
Blast.defineStatic('Function', function parallel(_forceAsync, _limit, _tasks, _callback) {

@@ -590,3 +590,3 @@ var stillStarting,

*/
Blast.defineStatic('Function', 'until', function until(test, task, callback) {
Blast.defineStatic('Function', function until(test, task, callback) {
return Blast.Collection.Function.asyncLoop(false, false, test, task, callback);

@@ -609,3 +609,3 @@ });

*/
Blast.defineStatic('Function', 'doUntil', function doUntil(task, test, callback) {
Blast.defineStatic('Function', function doUntil(task, test, callback) {
return Blast.Collection.Function.asyncLoop(true, false, test, task, callback);

@@ -645,3 +645,3 @@ });

*/
Blast.defineStatic('Function', 'doWhile', function doWhile(task, test, callback) {
Blast.defineStatic('Function', function doWhile(task, test, callback) {
return Blast.Collection.Function.asyncLoop(true, true, test, task, callback);

@@ -754,3 +754,3 @@ });

*/
Blast.defineStatic('Function', 'asyncLoop', function asyncLoop(atleastOnce, matchValue, testFnc, taskFnc, callback) {
Blast.defineStatic('Function', function asyncLoop(atleastOnce, matchValue, testFnc, taskFnc, callback) {

@@ -823,3 +823,3 @@ var handler,

*/
Blast.defineStatic('Function', 'hinder', function hinder(forceAsync, worker, options) {
Blast.defineStatic('Function', function hinder(forceAsync, worker, options) {

@@ -920,3 +920,3 @@ var scheduler,

*/
Blast.defineStatic('Function', 'doUnitTime', function doUnitTime(amount, ms, task, callback) {
Blast.defineStatic('Function', function doUnitTime(amount, ms, task, callback) {

@@ -1025,3 +1025,3 @@ var recursion,

*/
Blast.defineStatic('Function', 'doTime', function doTime(ms, task, callback) {
Blast.defineStatic('Function', function doTime(ms, task, callback) {
return Collection.Function.doUnitTime(0, ms, task, callback);

@@ -1042,3 +1042,3 @@ });

*/
Blast.defineStatic('Function', 'doAmount', function doAmount(amount, task, callback) {
Blast.defineStatic('Function', function doAmount(amount, task, callback) {
return Collection.Function.doUnitTime(amount, 0, task, callback);

@@ -1058,3 +1058,3 @@ });

*/
Blast.defineStatic('Function', 'count', function count(fnc) {
Blast.defineStatic('Function', function count(fnc) {

@@ -1091,3 +1091,3 @@ var count = 0;

*/
Blast.defineStatic('Function', 'regulate', function regulate(fnc, amount, overflow) {
Blast.defineStatic('Function', function regulate(fnc, amount, overflow) {

@@ -1136,3 +1136,3 @@ var count = 0;

* @since 0.1.9
* @version 0.3.6
* @version 0.6.2
*

@@ -1146,15 +1146,33 @@ * @param {Function} fnc Function to throttle

*/
Blast.defineStatic('Function', 'throttle', function throttle(fnc, minimum_wait, immediate, reset_on_call) {
Blast.defineStatic('Function', function throttle(fnc, minimum_wait, immediate, reset_on_call) {
var last_exec_time = 0,
queued;
var last_exec_time = Symbol('last_exec_time'),
queued = Symbol('queued'),
config,
state;
if (!minimum_wait) {
minimum_wait = 5;
if (!minimum_wait || typeof minimum_wait != 'object') {
config = {
minimum_wait : minimum_wait,
immediate : immediate,
reset_on_call : reset_on_call
};
} else {
config = minimum_wait;
}
state = {};
state[last_exec_time] = 0;
state[queued] = null;
if (!config.minimum_wait) {
config.minimum_wait = 5;
}
return function wrapper() {
var prev_exec_time = last_exec_time,
var prev_exec_time,
ms_since_last_exec,
minimum_wait = config.minimum_wait,
context,
that,

@@ -1164,2 +1182,10 @@ args,

if (config.method) {
context = this;
} else {
context = state;
}
prev_exec_time = context[last_exec_time];
// Get the current timestamp

@@ -1171,4 +1197,4 @@ now = Date.now();

// set the last and prev timestamps to NOW
if (!last_exec_time && !immediate) {
last_exec_time = now;
if (!context[last_exec_time] && !config.immediate) {
context[last_exec_time] = now;
prev_exec_time = now;

@@ -1181,9 +1207,9 @@ }

// If there has been no execution yet, or the waiting time is over
if (!last_exec_time || (ms_since_last_exec > minimum_wait)) {
if (!context[last_exec_time] || (ms_since_last_exec > minimum_wait)) {
if (queued) {
clearTimeout(queued);
if (context[queued]) {
clearTimeout(context[queued]);
}
if (reset_on_call === true) {
if (config.reset_on_call === true) {
// If reset_on_call is true the waiting time starts again,

@@ -1194,3 +1220,3 @@ // the call will be queued in the next if block

fnc.apply(this, arguments);
last_exec_time = now;
context[last_exec_time] = now;
return;

@@ -1204,9 +1230,9 @@ }

if (queued) {
clearTimeout(queued);
if (context[queued]) {
clearTimeout(context[queued]);
}
queued = setTimeout(function throttleQueue() {
queued = null;
last_exec_time = Date.now();
context[queued] = setTimeout(function throttleQueue() {
context[queued] = null;
context[last_exec_time] = Date.now();
fnc.apply(that, args);

@@ -1227,5 +1253,5 @@ }, minimum_wait - ms_since_last_exec);

*/
Blast.defineStatic('Function', 'createQueue', function createQueue(options) {
Blast.defineStatic('Function', function createQueue(options) {
return new Blast.Classes.FunctionQueue(options);
});
};

@@ -324,3 +324,3 @@ module.exports = function BlastInheritance(Blast, Collection) {

*/
Blast.defineStatic('Function', 'inherits', function inherits(_parent, _namespace, _newConstructor, _do_constitutors) {
Blast.defineStatic('Function', function inherits(_parent, _namespace, _newConstructor, _do_constitutors) {

@@ -684,3 +684,3 @@ var parent_namespace,

*/
Blast.defineStatic('Function', 'doConstitutors', doConstitutors);
Blast.defineStatic('Function', doConstitutors);

@@ -725,3 +725,3 @@ /**

*/
Blast.defineStatic('Function', 'constitute', function constitute(constructor, task) {
Blast.defineStatic('Function', function constitute(constructor, task) {

@@ -771,3 +771,3 @@ var tasks = constructor.constitutors;

*/
Blast.defineStatic('Function', 'staticCompose', function staticCompose(target, key, constructor, traits) {
Blast.defineStatic('Function', function staticCompose(target, key, constructor, traits) {

@@ -803,3 +803,3 @@ var data;

*/
Blast.defineStatic('Function', 'compose', function compose(target, key, compositor, traits) {
Blast.defineStatic('Function', function compose(target, key, compositor, traits) {

@@ -912,3 +912,3 @@ var methodDefiner,

*/
Blast.defineStatic('Function', 'setStatic', function setStatic(target, _key, _value, _inherit) {
Blast.defineStatic('Function', function setStatic(target, _key, _value, _inherit) {

@@ -967,3 +967,3 @@ var enumerable,

*/
Blast.defineStatic('Function', 'setStaticProperty', function setStaticProperty(target, _key, _getter, _setter, _inherit) {
Blast.defineStatic('Function', function setStaticProperty(target, _key, _getter, _setter, _inherit) {

@@ -1042,3 +1042,3 @@ var enumerable,

*/
Blast.defineStatic('Function', 'setMethod', function setMethod(constructor, _key, _method) {
Blast.defineStatic('Function', function setMethod(constructor, _key, _method) {

@@ -1119,3 +1119,3 @@ var existing,

*/
Blast.defineStatic('Function', 'decorateMethod', function decorateMethod(constructor, decorator, key, method) {
Blast.defineStatic('Function', function decorateMethod(constructor, decorator, key, method) {

@@ -1176,3 +1176,3 @@ var options

*/
Blast.defineStatic('Function', 'setProperty', function setProperty(constructor, _key, _getter, _setter) {
Blast.defineStatic('Function', function setProperty(constructor, _key, _getter, _setter) {

@@ -1270,3 +1270,3 @@ var enumerable,

*/
Blast.defineStatic('Function', 'prepareProperty', function prepareProperty(target, _key, _getter, _enumerable) {
Blast.defineStatic('Function', function prepareProperty(target, _key, _getter, _enumerable) {

@@ -1382,3 +1382,3 @@ var enumerable,

*/
Blast.defineStatic('Function', 'getChildren', function getChildren(constructor) {
Blast.defineStatic('Function', function getChildren(constructor) {

@@ -1418,3 +1418,3 @@ var result = [];

Blast.definePrototype('Function', 'extend', protoExtend);
Blast.definePrototype('Function', protoExtend);

@@ -1596,13 +1596,13 @@ /**

if (typeof newConstructor.setMethod !== 'function') {
Blast.defineValue(newConstructor, 'prepareStaticProperty', protoPrepareStaticProperty);
Blast.defineValue(newConstructor, 'setStaticProperty', protoSetStaticProperty);
Blast.defineValue(newConstructor, 'prepareProperty', protoPrepareProperty);
Blast.defineValue(newConstructor, 'decorateMethod', protoDecorateMethod);
Blast.defineValue(newConstructor, 'staticCompose', protoStaticCompose);
Blast.defineValue(newConstructor, 'getChildren', protoGetChildren);
Blast.defineValue(newConstructor, 'setProperty', protoSetProperty);
Blast.defineValue(newConstructor, 'constitute', protoConstitute);
Blast.defineValue(newConstructor, 'setStatic', protoSetStatic);
Blast.defineValue(newConstructor, 'setMethod', protoSetMethod);
Blast.defineValue(newConstructor, 'compose', protoCompose);
Blast.defineValue(newConstructor, protoPrepareStaticProperty);
Blast.defineValue(newConstructor, protoSetStaticProperty);
Blast.defineValue(newConstructor, protoPrepareProperty);
Blast.defineValue(newConstructor, protoDecorateMethod);
Blast.defineValue(newConstructor, protoStaticCompose);
Blast.defineValue(newConstructor, protoGetChildren);
Blast.defineValue(newConstructor, protoSetProperty);
Blast.defineValue(newConstructor, protoConstitute);
Blast.defineValue(newConstructor, protoSetStatic);
Blast.defineValue(newConstructor, protoSetMethod);
Blast.defineValue(newConstructor, protoCompose);

@@ -1615,15 +1615,15 @@ if (newConstructor.extend == null) {

Blast.definePrototype('Function', 'prepareStaticProperty', protoPrepareStaticProperty);
Blast.definePrototype('Function', 'setStaticProperty', protoSetStaticProperty);
Blast.definePrototype('Function', 'prepareProperty', protoPrepareProperty);
Blast.definePrototype('Function', 'decorateMethod', protoDecorateMethod);
Blast.definePrototype('Function', 'staticCompose', protoStaticCompose);
Blast.definePrototype('Function', 'getChildren', protoGetChildren);
Blast.definePrototype('Function', 'setProperty', protoSetProperty);
Blast.definePrototype('Function', 'constitute', protoConstitute);
Blast.definePrototype('Function', 'setStatic', protoSetStatic);
Blast.definePrototype('Function', 'setMethod', protoSetMethod);
Blast.definePrototype('Function', 'compose', protoCompose);
Blast.definePrototype('Function', protoPrepareStaticProperty);
Blast.definePrototype('Function', protoSetStaticProperty);
Blast.definePrototype('Function', protoPrepareProperty);
Blast.definePrototype('Function', protoDecorateMethod);
Blast.definePrototype('Function', protoStaticCompose);
Blast.definePrototype('Function', protoGetChildren);
Blast.definePrototype('Function', protoSetProperty);
Blast.definePrototype('Function', protoConstitute);
Blast.definePrototype('Function', protoSetStatic);
Blast.definePrototype('Function', protoSetMethod);
Blast.definePrototype('Function', protoCompose);
var Fn = Blast.Collection.Function;
};

@@ -325,3 +325,3 @@ module.exports = function BlastFunction(Blast, Collection) {

*/
Blast.defineStatic('Function', 'getArgumentNames', function getArgumentNames(fnc) {
Blast.defineStatic('Function', function getArgumentNames(fnc) {

@@ -360,35 +360,2 @@ var result = [],

/**
* Function's should really have a name property,
* this is not yet implemented in IE9, IE10 or IE11.
* Because this is so important to Protoblast,
* it's always added to the prototype.
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.1.3
* @version 0.1.4
*
* @return {String}
*/
Blast.defineGet(Function.prototype, 'name', function name() {
var fncName;
// Turn the function into a string and extract the name using a regex
fncName = this.toString().match(/^\s*function\s*(\S*)\s*\(/);
// If no name is found, use an empty string
if (!fncName || !fncName[1]) {
fncName = '';
} else {
fncName = fncName[1];
}
// Store the name property on the function itself
this.name = fncName;
// Return the name
return fncName;
});
/**
* Convert this function sourcecode to tokens

@@ -405,3 +372,3 @@ *

*/
Blast.definePrototype('Function', 'tokenize', function tokenize(addType, throwErrors) {
Blast.definePrototype('Function', function tokenize(addType, throwErrors) {
return Collection.Function.tokenize(''+this, addType, throwErrors);

@@ -419,3 +386,3 @@ });

*/
Blast.definePrototype('Function', 'getBodySource', function getBodySource() {
Blast.definePrototype('Function', function getBodySource() {

@@ -460,3 +427,3 @@ // Get the source code of the function

*/
Blast.definePrototype('Function', 'methodize', function methodize(name) {
Blast.definePrototype('Function', function methodize(name) {

@@ -525,3 +492,3 @@ var sourcecode,

*/
Blast.definePrototype('Function', 'unmethodize', function unmethodize(name) {
Blast.definePrototype('Function', function unmethodize(name) {

@@ -563,59 +530,2 @@ var sourcecode,

/**
* Create a function that already contains pre-filled-in arguments
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.1.0
* @version 0.5.1
*
* @return {Function}
*/
Blast.definePrototype('Function', 'curry', function curry() {
var curried_source,
sourcecode,
curry_args,
curried,
name,
fnc,
i;
// If no arguments are given, return the same function
if (arguments.length === 0) {
return this;
}
fnc = this;
// Keep function optimized by not leaking the `arguments` object
curry_args = new Array(arguments.length);
for (i = 0; i < curry_args.length; i++) curry_args[i] = arguments[i];
curried_source = function () {
var args,
i;
// Clone the pre-filled arguments
args = curry_args.slice(0);
// Add the new arguments
for (i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
// Apply the original function, with the curent context
return fnc.apply(this, args);
};
name = fnc.name || '';
// Get the sourcecode
sourcecode = 'function ' + name + String(curried_source).slice(9);
eval('curried = ' + sourcecode);
return curried;
});
/**
* Make this function listen to the event on the given object

@@ -630,3 +540,3 @@ *

*/
Blast.definePrototype('Function', 'listenTo', function listenTo(event, context) {
Blast.definePrototype('Function', function listenTo(event, context) {

@@ -668,3 +578,3 @@ var method;

*/
Blast.definePrototype('Function', 'unListen', function unListen(event, context) {
Blast.definePrototype('Function', function unListen(event, context) {

@@ -708,3 +618,3 @@ var method;

*/
Blast.defineStatic('Function', 'tryCatch', function tryCatch(fnc, args, context) {
Blast.defineStatic('Function', function tryCatch(fnc, args, context) {
try {

@@ -711,0 +621,0 @@ if (context) {

@@ -216,3 +216,3 @@ /**

*/
Blast.definePrototype('String', 'pluralize', function pluralize(plural) {
Blast.definePrototype('String', function pluralize(plural) {
return InflectionJS.apply_rules(

@@ -237,3 +237,3 @@ this,

*/
Blast.definePrototype('String', 'singularize', function singularize(singular) {
Blast.definePrototype('String', function singularize(singular) {
return InflectionJS.apply_rules(

@@ -258,3 +258,3 @@ this,

*/
Blast.definePrototype('String', 'modelName', function modelName(postfix) {
Blast.definePrototype('String', function modelName(postfix) {

@@ -307,3 +307,3 @@ var str = this,

*/
Blast.definePrototype('String', 'modelClassName', function modelClassName() {
Blast.definePrototype('String', function modelClassName() {

@@ -334,3 +334,3 @@ var result;

*/
Blast.definePrototype('String', 'controllerName', function controllerName(postfix) {
Blast.definePrototype('String', function controllerName(postfix) {

@@ -390,3 +390,3 @@ var str = this,

*/
Blast.definePrototype('String', 'controllerClassName', function controllerClassName() {
Blast.definePrototype('String', function controllerClassName() {

@@ -418,3 +418,3 @@ var result;

*/
Blast.definePrototype('String', 'camelize', function camelize(lowFirstLetter) {
Blast.definePrototype('String', function camelize(lowFirstLetter) {

@@ -459,3 +459,3 @@ var str = this,

*/
Blast.definePrototype('String', 'underscore', function underscore() {
Blast.definePrototype('String', function underscore() {

@@ -492,3 +492,3 @@ var str = this,

*/
Blast.definePrototype('String', 'humanize', function humanize(lowFirstLetter) {
Blast.definePrototype('String', function humanize(lowFirstLetter) {

@@ -524,3 +524,3 @@ var str = S.underscore(this),

*/
Blast.definePrototype('String', 'capitalize', function capitalize() {
Blast.definePrototype('String', function capitalize() {

@@ -545,3 +545,3 @@ // Lowercase the complete string

*/
Blast.definePrototype('String', 'dasherize', function dasherize() {
Blast.definePrototype('String', function dasherize() {
var str = this;

@@ -563,3 +563,3 @@ str = str.replace(InflectionJS.space_or_underbar, '-');

*/
Blast.definePrototype('String', 'titleize', function titleize(alwaysCapitalize) {
Blast.definePrototype('String', function titleize(alwaysCapitalize) {

@@ -608,3 +608,3 @@ // Underscore the string

*/
Blast.definePrototype('String', 'demodulize', function demodulize() {
Blast.definePrototype('String', function demodulize() {

@@ -628,3 +628,3 @@ var str = this,

*/
Blast.definePrototype('String', 'tableize', function tableize() {
Blast.definePrototype('String', function tableize() {
var str = S.underscore(this);

@@ -644,3 +644,3 @@ str = S.pluralize(str);

*/
Blast.definePrototype('String', 'classify', function classify() {
Blast.definePrototype('String', function classify() {
var str = S.camelize(this);

@@ -662,3 +662,3 @@ str = S.singularize(str);

*/
Blast.definePrototype('String', 'foreign_key', function foreign_key(dropIdUbar) {
Blast.definePrototype('String', function foreign_key(dropIdUbar) {
var str = S.demodulize(this);

@@ -680,3 +680,3 @@ str = S.underscore(str);

*/
Blast.definePrototype('String', 'ordinalize', function ordinalize() {
Blast.definePrototype('String', function ordinalize() {

@@ -730,3 +730,3 @@ var str = this,

*/
Blast.definePrototype('String', 'deplugin', function deplugin(str) {
Blast.definePrototype('String', function deplugin(str) {

@@ -733,0 +733,0 @@ var s = this.split('.'),

@@ -219,2 +219,3 @@ module.exports = function BlastInitLoader(modifyPrototype) {

'Informer',
'State',
'Request',

@@ -306,3 +307,3 @@ 'FunctionQueue',

* @since 0.1.0
* @version 0.6.0
* @version 0.6.2
*

@@ -319,2 +320,8 @@ * @param {Object} target The object to add the property to

if (typeof name == 'function') {
descriptor = value;
value = name;
name = value.name;
}
if (descriptor == null) {

@@ -399,2 +406,35 @@ descriptor = {};

/**
* Function's should really have a name property,
* this is not yet implemented in IE9, IE10 or IE11.
* Because this is so important to Protoblast,
* it's always added to the prototype.
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.1.3
* @version 0.1.4
*
* @return {String}
*/
Blast.defineGet(Function.prototype, 'name', function name() {
var fncName;
// Turn the function into a string and extract the name using a regex
fncName = this.toString().match(/^\s*function\s*(\S*)\s*\(/);
// If no name is found, use an empty string
if (!fncName || !fncName[1]) {
fncName = '';
} else {
fncName = fncName[1];
}
// Store the name property on the function itself
this.name = fncName;
// Return the name
return fncName;
});
/**
* Define a class constructor.

@@ -467,3 +507,3 @@ * Always returns the given constructor.

* @since 0.1.0
* @version 0.1.12
* @version 0.6.2
*

@@ -480,10 +520,19 @@ * @param {Object} target The object to add the property to

className,
definer;
definer,
length = arguments.length;
if (arguments.length == 3) {
if (typeof name == 'function') {
length += 1;
shim = value;
value = type;
type = name;
name = type.name;
}
if (length == 3) {
value = type;
type = 'value';
}
if (arguments.length == 4) {
if (length == 4) {
if (typeof value == 'boolean') {

@@ -575,3 +624,3 @@ shim = value;

* @since 0.1.0
* @version 0.4.2
* @version 0.6.2
*

@@ -589,2 +638,8 @@ * @param {Object} target The object to add the property to

if (typeof name == 'function') {
shim = value;
value = name;
name = value.name;
}
if (typeof targetClass == 'string') {

@@ -753,3 +808,3 @@

// This file should only be for browsers
files.push('browsershims');
files.push('browsershims', 'request_browser');

@@ -802,5 +857,3 @@ files.forEach(function eachFile(name, index) {

client_extras.push({
name : options.name
});
client_extras.push(options.name);
});

@@ -975,2 +1028,3 @@

//PROTOBLAST START CUT
/**

@@ -1025,2 +1079,3 @@ * Check require call

}
//PROTOBLAST END CUT

@@ -1071,11 +1126,10 @@ /**

//PROTOBLAST START CUT
if (!options.path) {
if (libpath) {
if (name == libpath.basename(name)) {
options.name = name;
options.path = libpath.resolve(__dirname, name + '.js');
} else {
options.path = name;
options.name = libpath.basename(options.path);
}
if (name == libpath.basename(name)) {
options.name = name;
options.path = libpath.resolve(__dirname, name + '.js');
} else {
options.path = name;
options.name = libpath.basename(options.path);
}

@@ -1090,2 +1144,3 @@ }

checkNextRequire(options);
//PROTOBLAST END CUT

@@ -1100,3 +1155,6 @@ // Get the exported function

return result;
} else if (require.cache) {
}
//PROTOBLAST START CUT
if (require.cache) {
// Try getting the actual exported module

@@ -1111,2 +1169,3 @@ exported_module = require.cache[options.path || name];

}
//PROTOBLAST END CUT
};

@@ -1157,5 +1216,6 @@

Blast.require('browsershims');
Blast.require('request_browser');
client_extras.forEach(function eachExtra(options) {
Blast.require(options.name);
client_extras.forEach(function eachExtra(name) {
Blast.require(name);
});

@@ -1234,3 +1294,6 @@ }

// Create the state instance
Blast.state = new Blast.Classes.State();
return Blast;
};

@@ -102,3 +102,3 @@ 'use strict';

*/
Blast.defineStatic('JSON', 'safeParse', function safeParse(text, reviver) {
Blast.defineStatic('JSON', function safeParse(text, reviver) {
try {

@@ -105,0 +105,0 @@ return JSON.parse(text, reviver);

@@ -66,3 +66,3 @@ module.exports = function BlastPath(Blast, Collection) {

*/
Blast.defineValue(JSONPath.prototype, 'normalize', function normalize(expr) {
Blast.defineValue(JSONPath.prototype, function normalize(expr) {

@@ -101,3 +101,3 @@ var normalized,

*/
Blast.defineValue(JSONPath.prototype, 'asPath', function asPath(path) {
Blast.defineValue(JSONPath.prototype, function asPath(path) {

@@ -125,3 +125,3 @@ var i, p, x;

*/
Blast.defineValue(JSONPath.prototype, 'trace', function trace(expr, val, path) {
Blast.defineValue(JSONPath.prototype, function trace(expr, val, path) {

@@ -201,3 +201,3 @@ var that = this,

*/
Blast.defineValue(JSONPath.prototype, 'walk', function walk(loc, expr, val, path, f) {
Blast.defineValue(JSONPath.prototype, function walk(loc, expr, val, path, f) {

@@ -226,3 +226,3 @@ var i, m, n;

*/
Blast.defineValue(JSONPath.prototype, 'slice', function slice(loc, expr, val, path) {
Blast.defineValue(JSONPath.prototype, function slice(loc, expr, val, path) {
if (!Array.isArray(val)) return;

@@ -247,3 +247,3 @@ var len = val.length, parts = loc.split(':'),

*/
Blast.defineValue(JSONPath.prototype, 'eval', function eval(code, _v, _vname, path) {
Blast.defineValue(JSONPath.prototype, function eval(code, _v, _vname, path) {
if (!$ || !_v) return false;

@@ -279,3 +279,3 @@ if (code.indexOf("@path") > -1) {

*/
Blast.defineValue(JSONPath.prototype, 'exec', function exec(obj, resultType) {
Blast.defineValue(JSONPath.prototype, function exec(obj, resultType) {

@@ -282,0 +282,0 @@ var that = this,

@@ -14,3 +14,3 @@ module.exports = function BlastMath(Blast, Collection, Bound) {

*/
Blast.defineStatic('Math', 'lowest', function lowest(numbers, amount) {
Blast.defineStatic('Math', function lowest(numbers, amount) {

@@ -45,3 +45,3 @@ var result,

*/
Blast.defineStatic('Math', 'highest', function highest(numbers, amount) {
Blast.defineStatic('Math', function highest(numbers, amount) {

@@ -80,3 +80,3 @@ var result,

*/
Blast.defineStatic('Math', 'clip', function clip(numbers, lowest, highest) {
Blast.defineStatic('Math', function clip(numbers, lowest, highest) {
return Bound.Array.clip(numbers.slice(0), lowest, highest);

@@ -94,3 +94,3 @@ });

*/
Blast.defineStatic('Math', 'sum', function sum(arr) {
Blast.defineStatic('Math', function sum(arr) {

@@ -127,3 +127,3 @@ var numbers,

*/
Blast.defineStatic('Math', 'mean', function mean(arr) {
Blast.defineStatic('Math', function mean(arr) {

@@ -157,3 +157,3 @@ var numbers,

*/
Blast.defineStatic('Math', 'standardize', function standardize(arr) {
Blast.defineStatic('Math', function standardize(arr) {

@@ -199,3 +199,3 @@ var deviations,

*/
Blast.defineStatic('Math', 'variance', function variance(arr, _bias) {
Blast.defineStatic('Math', function variance(arr, _bias) {

@@ -241,3 +241,3 @@ var deviations,

*/
Blast.defineStatic('Math', 'covariance', function variance(arrA, arrB) {
Blast.defineStatic('Math', function covariance(arrA, arrB) {

@@ -275,3 +275,3 @@ var length,

*/
Blast.defineStatic('Math', 'pearson', function pearson(arrX, arrY) {
Blast.defineStatic('Math', function pearson(arrX, arrY) {

@@ -324,3 +324,3 @@ var sumXS = 0,

*/
Blast.defineStatic('Math', 'spearman', function spearman(arrX, arrY) {
Blast.defineStatic('Math', function spearman(arrX, arrY) {

@@ -368,3 +368,3 @@ var sigma = 0,

*/
Blast.defineStatic('Math', 'deviation', function deviation(arr) {
Blast.defineStatic('Math', function deviation(arr) {

@@ -409,3 +409,3 @@ var numbers,

*/
Blast.defineStatic('Math', 'standardDeviation', function standardDeviation(arr, _bias, relative) {
Blast.defineStatic('Math', function standardDeviation(arr, _bias, relative) {

@@ -451,3 +451,3 @@ var numbers,

*/
Blast.defineStatic('Math', 'median', function median(arr) {
Blast.defineStatic('Math', function median(arr) {

@@ -496,3 +496,3 @@ var numbers,

*/
Blast.defineStatic('Math', 'easeInOutQuad', function easeInOutQuad(t, b, c, d) {
Blast.defineStatic('Math', function easeInOutQuad(t, b, c, d) {
t /= d/2;

@@ -518,3 +518,3 @@ if (t < 1) return c/2*t*t + b;

*/
Blast.defineStatic('Math', 'overlaps', function overlaps(a1, b1, a2, b2) {
Blast.defineStatic('Math', function overlaps(a1, b1, a2, b2) {

@@ -544,3 +544,3 @@ if (Array.isArray(a1)) {

*/
Blast.defineStatic('Math', 'lowpass', function lowpass(input, alpha, first) {
Blast.defineStatic('Math', function lowpass(input, alpha, first) {

@@ -598,3 +598,3 @@ var output = [],

*/
Blast.defineStatic('Math', 'interpolate', function interpolate(input, newlength) {
Blast.defineStatic('Math', function interpolate(input, newlength) {

@@ -639,3 +639,3 @@ var output = [],

*/
Blast.defineStatic('Math', 'plotdate', function plotdate(values, dates, unit) {
Blast.defineStatic('Math', function plotdate(values, dates, unit) {

@@ -736,3 +736,3 @@ var ovalues = [],

*/
Blast.defineStatic('Math', 'removeOutliers', function removeOutliers(arr, clip) {
Blast.defineStatic('Math', function removeOutliers(arr, clip) {

@@ -855,3 +855,3 @@ var filtered_values,

*/
Blast.defineStatic('Math', 'round10', function round10(value, exp) {
Blast.defineStatic('Math', function round10(value, exp) {
return decimalAdjust('round', value, exp);

@@ -872,3 +872,3 @@ });

*/
Blast.defineStatic('Math', 'floor10', function floor10(value, exp) {
Blast.defineStatic('Math', function floor10(value, exp) {
return decimalAdjust('floor', value, exp);

@@ -889,3 +889,3 @@ });

*/
Blast.defineStatic('Math', 'ceil10', function ceil10(value, exp) {
Blast.defineStatic('Math', function ceil10(value, exp) {
return decimalAdjust('ceil', value, exp);

@@ -905,3 +905,3 @@ });

*/
Blast.defineStatic('Math', 'degreesToRadians', function degreesToRadians(degrees) {
Blast.defineStatic('Math', function degreesToRadians(degrees) {
return degrees * (Math.PI/180);

@@ -924,3 +924,3 @@ });

*/
Blast.defineStatic('Math', 'calculateDistance', function calculateDistance(lat1, lon1, lat2, lon2) {
Blast.defineStatic('Math', function calculateDistance(lat1, lon1, lat2, lon2) {

@@ -958,5 +958,5 @@ var rad_lat1,

*/
Blast.defineStatic('Math', 'createSeededRng', function createSeededRng(seed) {
Blast.defineStatic('Math', function createSeededRng(seed) {
return new Blast.Classes.SeededRng(seed);
});
};

@@ -22,3 +22,3 @@ module.exports = function BlastNumber(Blast, Collection) {

*/
Blast.defineStatic('Number', 'random', function random(min, max) {
Blast.defineStatic('Number', function random(min, max) {

@@ -54,3 +54,3 @@ if (typeof max === 'undefined') {

*/
Blast.defineStatic('Number', 'clip', function clip(value, lowest, highest) {
Blast.defineStatic('Number', function clip(value, lowest, highest) {

@@ -84,3 +84,3 @@ // Return `lowest` if the value is under the threshold

*/
Blast.defineStatic('Number', 'calculateNormalizeFactors', function calculateNormalizeFactors(input, scale) {
Blast.defineStatic('Number', function calculateNormalizeFactors(input, scale) {
return {

@@ -106,3 +106,3 @@ input_min : Math.min.apply(Math, input),

*/
Blast.defineStatic('Number', 'normalize', function normalize(input, scale) {
Blast.defineStatic('Number', function normalize(input, scale) {

@@ -135,3 +135,3 @@ var result = new Array(input.length),

*/
Blast.defineStatic('Number', 'denormalize', function denormalize(input, scale) {
Blast.defineStatic('Number', function denormalize(input, scale) {

@@ -159,3 +159,3 @@ var result = new Array(input.length),

*/
Blast.defineStatic('Number', 'isNumeric', function isNumeric(input) {
Blast.defineStatic('Number', function isNumeric(input) {

@@ -182,3 +182,3 @@ if (typeof input == 'number') {

*/
Blast.definePrototype('Number', 'toPaddedString', function toPaddedString(length, radix) {
Blast.definePrototype('Number', function toPaddedString(length, radix) {
var str = this.toString(radix || 10);

@@ -200,3 +200,3 @@ return Blast.Bound.String.multiply('0', length - str.length) + str;

*/
Blast.definePrototype('Number', 'humanize', function humanize(delimiter, separator) {
Blast.definePrototype('Number', function humanize(delimiter, separator) {

@@ -223,3 +223,3 @@ var str = this.toString().split('.');

*/
Blast.definePrototype('Number', 'clip', function clip(lowest, highest) {
Blast.definePrototype('Number', function clip(lowest, highest) {
return Collection.Number.clip(this, lowest, highest);

@@ -241,3 +241,3 @@ });

*/
Blast.definePrototype('Number', 'toByte', function toByte(from, to, decimal) {
Blast.definePrototype('Number', function toByte(from, to, decimal) {

@@ -316,3 +316,3 @@ var fromBase,

*/
Blast.definePrototype('Number', 'bitAt', function bitAt(position) {
Blast.definePrototype('Number', function bitAt(position) {
return Number((this >> position) % 2 != 0);

@@ -332,3 +332,3 @@ });

*/
Blast.definePrototype('Number', 'toFixed10', function toFixed10(precision) {
Blast.definePrototype('Number', function toFixed10(precision) {
return Collection.Math.round10(this, -precision).toFixed(precision);

@@ -350,3 +350,3 @@ });

*/
Blast.definePrototype('Number', 'formatMoney', function formatMoney(decimal_count, decimal_separator, thousand_separator) {
Blast.definePrototype('Number', function formatMoney(decimal_count, decimal_separator, thousand_separator) {

@@ -353,0 +353,0 @@ var number_without_decimals,

@@ -18,3 +18,3 @@ module.exports = function BlastObject(Blast, Collection, Bound, Obj) {

*/
Blast.defineStatic('Object', 'getPropertyDescriptor', function getPropertyDescriptor(target, key) {
Blast.defineStatic('Object', function getPropertyDescriptor(target, key) {

@@ -56,3 +56,3 @@ var proto,

*/
Blast.defineStatic('Object', 'isObject', function isObject(obj) {
Blast.defineStatic('Object', function isObject(obj) {
return !(!obj || typeof obj != 'object');

@@ -73,3 +73,3 @@ });

*/
Blast.defineStatic('Object', 'isPlainObject', function isPlainObject(obj) {
Blast.defineStatic('Object', function isPlainObject(obj) {
return !!(obj && (!obj.constructor || obj.constructor.name == 'Object'));

@@ -89,3 +89,3 @@ });

*/
Blast.defineStatic('Object', 'isPrimitiveObject', function isPrimitiveObject(obj) {
Blast.defineStatic('Object', function isPrimitiveObject(obj) {

@@ -123,3 +123,3 @@ var id;

*/
Blast.defineStatic('Object', 'isPrimitive', function isPrimitive(arg) {
Blast.defineStatic('Object', function isPrimitive(arg) {

@@ -146,3 +146,3 @@ var type = typeof arg;

*/
Blast.defineStatic('Object', 'stringifyPrimitive', function stringifyPrimitive(arg) {
Blast.defineStatic('Object', function stringifyPrimitive(arg) {

@@ -179,3 +179,3 @@ switch (typeof arg) {

*/
Blast.defineStatic('Object', 'size', function size(obj, includeUndefined) {
Blast.defineStatic('Object', function size(obj, includeUndefined) {

@@ -255,3 +255,3 @@ var type,

*/
Blast.defineStatic('Object', 'sizeof', function sizeof(input) {
Blast.defineStatic('Object', function sizeof(input) {
return calculate_sizeof(input, new WeakMap());

@@ -360,3 +360,3 @@ });

*/
Blast.defineStatic('Object', 'flatten', function flatten(obj, divider, flatten_arrays) {
Blast.defineStatic('Object', function flatten(obj, divider, flatten_arrays) {
return flatten_object(obj, divider, 0, flatten_arrays);

@@ -465,3 +465,3 @@ });

*/
Blast.defineStatic('Object', 'divide', function divide(obj) {
Blast.defineStatic('Object', function divide(obj) {

@@ -499,3 +499,3 @@ var list,

*/
Blast.defineStatic('Object', 'dissect', function disect(obj) {
Blast.defineStatic('Object', function dissect(obj) {

@@ -535,3 +535,3 @@ var list = [],

*/
Blast.defineStatic('Object', 'values', function values(obj) {
Blast.defineStatic('Object', function values(obj) {

@@ -560,3 +560,3 @@ var keys = Object.keys(obj),

*/
Blast.defineStatic('Object', 'entries', function entries(obj) {
Blast.defineStatic('Object', function entries(obj) {

@@ -585,3 +585,3 @@ var keys = Object.keys(obj),

*/
Blast.defineStatic('Object', 'parseDotNotationPath', function parseDotNotationPath(path) {
Blast.defineStatic('Object', function parseDotNotationPath(path) {

@@ -611,3 +611,3 @@ if (Array.isArray(path)) {

*/
Blast.defineStatic('Object', 'path', function path(obj, pathString) {
Blast.defineStatic('Object', function path(obj, pathString) {

@@ -659,3 +659,3 @@ var pieces,

*/
Blast.defineStatic('Object', 'setPath', function setPath(obj, path, value, skipLastEntry, allow_prototype) {
Blast.defineStatic('Object', function setPath(obj, path, value, skipLastEntry, allow_prototype) {

@@ -738,3 +738,3 @@ var argLength = arguments.length,

*/
Blast.defineStatic('Object', 'getNextIndex', function getNextIndex(obj) {
Blast.defineStatic('Object', function getNextIndex(obj) {

@@ -776,3 +776,3 @@ var keys,

*/
Blast.defineStatic('Object', 'formPath', function formPath(obj, form_path) {
Blast.defineStatic('Object', function formPath(obj, form_path) {
var path = Blast.Classes.RURL.parseFormPath(form_path);

@@ -791,3 +791,3 @@ return Collection.Object.path(obj, path);

*/
Blast.defineStatic('Object', 'setFormPath', function setFormPath(obj, form_path, value, skipLastEntry) {
Blast.defineStatic('Object', function setFormPath(obj, form_path, value, skipLastEntry) {
var path = Blast.Classes.RURL.parseFormPath(form_path);

@@ -810,3 +810,3 @@ return Collection.Object.setPath(obj, path, value, skipLastEntry);

*/
Blast.defineStatic('Object', 'exists', function exists(obj, path) {
Blast.defineStatic('Object', function exists(obj, path) {

@@ -846,3 +846,3 @@ var last;

*/
Blast.defineStatic('Object', 'isEmpty', function isEmpty(obj, include_prototype) {
Blast.defineStatic('Object', function isEmpty(obj, include_prototype) {

@@ -868,3 +868,3 @@ if (!obj) {

*/
Blast.defineStatic('Object', 'assign', function assign(target, first, second) {
Blast.defineStatic('Object', function assign(target, first, second) {

@@ -902,3 +902,3 @@ var length = arguments.length, extension, key, i;

*/
Blast.defineStatic('Object', 'inject', function inject(target, first, second) {
Blast.defineStatic('Object', function inject(target, first, second) {

@@ -946,3 +946,3 @@ var extension,

*/
Blast.defineStatic('Object', 'isSelfContained', function isSelfContained(obj) {
Blast.defineStatic('Object', function isSelfContained(obj) {

@@ -985,3 +985,3 @@ var id;

*/
Blast.defineStatic('Object', 'merge', function merge(target, first, second) {
Blast.defineStatic('Object', function merge(target, first, second) {

@@ -1051,3 +1051,3 @@ var length = arguments.length, extension, key, i, j;

*/
Blast.defineStatic('Object', 'objectify', function objectify(source, recursive, value) {
Blast.defineStatic('Object', function objectify(source, recursive, value) {

@@ -1113,3 +1113,3 @@ var result = {},

*/
Blast.defineStatic('Object', 'each', function each(obj, fnc) {
Blast.defineStatic('Object', function each(obj, fnc) {

@@ -1135,3 +1135,3 @@ var key;

*/
Blast.defineStatic('Object', 'walk', function walk(obj, fnc, limit, seen, wm) {
Blast.defineStatic('Object', function walk(obj, fnc, limit, seen, wm) {

@@ -1221,3 +1221,3 @@ var count,

*/
Blast.defineStatic('Object', 'map', function map(obj, fnc) {
Blast.defineStatic('Object', function map(obj, fnc) {

@@ -1253,3 +1253,3 @@ var isFunction = typeof fnc === 'function',

*/
Blast.defineStatic('Object', 'mapKeys', function mapKeys(obj, fnc) {
Blast.defineStatic('Object', function mapKeys(obj, fnc) {

@@ -1292,3 +1292,3 @@ var isFunction = typeof fnc === 'function',

*/
Blast.defineStatic('Object', 'getValueKey', function getValueKey(target, value) {
Blast.defineStatic('Object', function getValueKey(target, value) {

@@ -1329,3 +1329,3 @@ var result, key;

*/
Blast.defineStatic('Object', 'extract', function extract(obj, expr, arg) {
Blast.defineStatic('Object', function extract(obj, expr, arg) {
var P = new Blast.Classes.JSONPath(expr, arg);

@@ -1347,3 +1347,3 @@ return P.exec(obj);

*/
Blast.defineStatic('Object', 'hasProperty', function hasProperty(target, property) {
Blast.defineStatic('Object', function hasProperty(target, property) {

@@ -1369,3 +1369,3 @@ if (target == null || typeof target != 'object' || (typeof target[property] === 'undefined' && !(property in target))) {

*/
Blast.defineStatic('Object', 'hasValue', function hasValue(target, value) {
Blast.defineStatic('Object', function hasValue(target, value) {
return !(Collection.Object.getValueKey(target, value) === false);

@@ -1387,3 +1387,3 @@ });

*/
Blast.defineStatic('Object', 'checksum', function checksum(obj, sort_arrays, seen) {
Blast.defineStatic('Object', function checksum(obj, sort_arrays, seen) {

@@ -1568,3 +1568,3 @@ var split_length,

*/
Blast.defineStatic('Object', 'alike', function alike(a, b, seen) {
Blast.defineStatic('Object', function alike(a, b, seen) {

@@ -1713,3 +1713,3 @@ var index_a,

*/
Blast.defineStatic('Object', 'enumerateOwnProperties', function enumerateOwnProperties(obj) {
Blast.defineStatic('Object', function enumerateOwnProperties(obj) {

@@ -1738,3 +1738,3 @@ var result = {},

*/
Blast.defineStatic('Object', 'enumerateOwnDescriptors', function enumerateOwnDescriptors(obj) {
Blast.defineStatic('Object', function enumerateOwnDescriptors(obj) {

@@ -1775,3 +1775,3 @@ var result = {},

*/
Blast.defineStatic('Object', 'first', function first(obj) {
Blast.defineStatic('Object', function first(obj) {

@@ -1778,0 +1778,0 @@ var key;

@@ -10,3 +10,3 @@ module.exports = function BlastRegExp(Blast, Collection) {

*/
Blast.defineStatic('RegExp', 'isRegExp', function isRegExp(variable) {
Blast.defineStatic('RegExp', function isRegExp(variable) {
return Object.prototype.toString.call(variable) === '[object RegExp]';

@@ -26,3 +26,3 @@ });

*/
Blast.defineStatic('RegExp', 'escape', function escape(str) {
Blast.defineStatic('RegExp', function escape(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');

@@ -43,3 +43,3 @@ });

*/
Blast.defineStatic('RegExp', 'interpret', function interpret(pattern, flags) {
Blast.defineStatic('RegExp', function interpret(pattern, flags) {

@@ -66,3 +66,3 @@ var split = pattern.match(/^\/(.*?)\/([gim]*)$/);

*/
Blast.defineStatic('RegExp', 'combine', function combine() {
Blast.defineStatic('RegExp', function combine() {

@@ -129,3 +129,3 @@ var source,

*/
Blast.definePrototype('RegExp', 'getPattern', function getPattern() {
Blast.definePrototype('RegExp', function getPattern() {

@@ -153,3 +153,3 @@ var source = this.toString(),

*/
Blast.definePrototype('RegExp', 'getFlags', function getFlags() {
Blast.definePrototype('RegExp', function getFlags() {

@@ -177,3 +177,3 @@ var source = this.toString(),

*/
Blast.definePrototype('RegExp', 'execAll', function execAll(str) {
Blast.definePrototype('RegExp', function execAll(str) {

@@ -180,0 +180,0 @@ var result = [],

module.exports = function BlastRequest(Blast, Collection) {
var https,
http,
zlib;
var method_symbol = Symbol('method'),
url_symbol = Symbol('url');

@@ -13,10 +12,8 @@ /**

* @since 0.2.0
* @version 0.2.0
* @version 0.6.2
*
* @param {Object|RURL} options
*/
var Request = Collection.Function.inherits('Informer', 'Develry', function Request(options) {
if (!options) {
options = {};
}
// Empty headers object

@@ -31,241 +28,254 @@ this.headers = {};

// See if the url has already been specified
if (options.url) {
this.setUrl(options.url);
if (options) {
this.setOptions(options);
}
// Accept gzip by default
this.setHeader('accept-encoding', 'gzip');
if (Blast.isNode) {
// Accept gzip by default
this.setHeader('accept-encoding', 'gzip');
}
});
/**
* Set the URL to request
* Method info
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.2.0
* @version 0.5.7
* @since 0.6.2
* @version 0.6.2
*
* @param {URL|String} url
* @param {String}
*
* @return {Object}
*/
Request.setMethod(function setUrl(url) {
if (typeof url == 'string') {
this.url = Blast.Classes.RURL.parse(url);
} else {
this.url = url;
}
Request.setStatic('method_info', {
GET : [ , 1, 1, 1, 1, 1],
HEAD : [ , , 1, 1, 1 ],
POST : [1, 1, , , , 1],
PUT : [1, , , 1 ],
DELETE : [1, 1, , 1 ],
CONNECT : [ , 1 ],
OPTIONS : [ , 1, 1, 1 ],
TRACE : [ , , , 1 ],
PATCH : [1]
});
/**
* Set header
* Get method info
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.2.0
* @version 0.2.0
* @since 0.6.2
* @version 0.6.2
*
* @param {String} name
* @param {Mixed} value
* @param {String}
*
* @return {Object}
*/
Request.setMethod(function setHeader(name, value) {
Request.setStatic(function getMethodInfo(method) {
var key;
var result,
info;
// If `name` is an object,
// set its contents as headers
if (name && typeof name == 'object') {
for (key in name) {
this.setHeader(key, name[key]);
}
method = String(method).toUpperCase();
info = Request.method_info[method];
if (!info) {
return;
}
this.headers[String(name).toLowerCase()] = value;
result = {
name : method,
method : method,
has_body : !!info[0],
response_body : !!info[1],
safe : !!info[2],
idempotent : !!info[3],
cacheable : !!info[4],
allowed_in_form : !!info[5]
};
return result;
});
/**
* Actually make a request
* Is this an allowed method?
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.2.0
* @version 0.5.7
* @since 0.6.2
* @version 0.6.2
*
* @param {Object} options
* @param {Function} callback
* @param {String}
*
* @return {Boolean}
*/
Request.setMethod(function http_request(options, callback) {
Request.setStatic(function isAllowedMethod(method) {
return !!Request.method_info[String(method).toUpperCase()];
});
var that = this,
body_data,
protocol,
config,
body,
url,
req;
/**
* The HTTP method name to use
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @type {String}
*/
Request.setProperty(function method() {
if (typeof options == 'string') {
url = Blast.Classes.RURL.parse(options);
options = {};
} else if (typeof options.url == 'string') {
url = Blast.Classes.RURL.parse(options.url);
} else {
url = options.url;
if (this[method_symbol]) {
return this[method_symbol];
}
if (options.get) {
url.addQuery(options.get);
}
return 'GET';
}, function setMethod(method) {
if (options.head) {
url.addQuery(options.head);
}
method = String(method).toUpperCase();
config = {
host : url.hostname,
path : url.pathname + url.search,
port : url.port,
headers : options.headers || {}
};
if (url.protocol == 'https:') {
protocol = https;
} else {
protocol = http;
if (!Request.isAllowedMethod(method)) {
throw new Error('Method "' + method + '" is not allowed!');
}
if (options.head) {
config.method = 'HEAD';
}
return this[method_symbol] = method;
});
if (options.post) {
config.method = 'POST';
body_data = options.post;
}
/**
* Information on the HTTP method
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @type {Object}
*/
Request.setProperty(function method_info() {
return Request.getMethodInfo(this.method);
});
if (options.put) {
config.method = 'PUT';
body_data = options.put;
}
/**
* The URL
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @type {RURL}
*/
Request.setProperty(function url() {
return this[url_symbol];
}, function setUrl(url) {
return this.setUrl(url);
});
if (options.delete) {
config.method = 'DELETE';
body_data = options.delete;
}
/**
* Set options
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*/
Request.setMethod(function setOptions(options) {
if (options.options) {
config.method = 'OPTIONS';
}
var set_method,
info,
body,
get,
key;
if (options.patch) {
config.method = 'PATCH';
body_data = options.patch;
if (!options) {
return;
}
if (body_data) {
if (typeof body_data == 'object') {
config.headers['Content-Type'] = 'application/json';
body = JSON.stringify(body_data);
} else {
body = String(body_data);
}
config.headers['Content-Length'] = Buffer.byteLength(body, 'utf8');
if (typeof options == 'string' && RURL.isUrl(options)) {
return this.setUrl(options);
}
// Create the request
req = protocol.request(config, function gotResponse(res) {
for (key in options) {
info = Request.getMethodInfo(key);
var output,
gzip,
body = '';
if (info) {
if (!options[key]) {
continue;
}
// Set the request options on the response object
res.request_options = config;
// Skip setting the GET method if another one was already set
if (info.method == 'GET' && set_method) {
// Ignore
} else {
this.method = key;
set_method = true;
}
// Follow redirects if there are any
if (res.statusCode > 299 && res.statusCode < 400) {
// Increase the redirect count
that.redirect_count++;
// Override the URL to request
options.url = Blast.Classes.RURL.parse(res.headers['location'], url.protocol + '//' + config.host);
if (!options.headers) {
options.headers = {};
if (info.has_body) {
body = options[key];
}
// Set the previous URL as the referrer
options.headers.referrer = url.href;
return that.http_request(options, callback);
}
// If an error occurs, call the callback with it
res.on('error', function gotResponseError(err) {
callback(err, res);
});
// If the response is gzipped, unzip it
if (res.headers['content-encoding'] == 'gzip') {
gzip = zlib.createGunzip();
res.pipe(gzip);
output = gzip;
} else {
output = res;
this[key] = options[key];
}
}
if (options.get_stream) {
return callback(null, res, output);
}
if (body) {
this.body = body;
}
// Listen for data to stream in
output.on('data', function gotData(data) {
body += data.toString('utf-8');
});
if (options.get) {
this.get = options.get;
}
output.on('end', function ended() {
});
var error_data,
error;
/**
* Set the URL to request
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.2.0
* @version 0.6.2
*
* @param {URL|String} url
*/
Request.setMethod(function setUrl(url, origin) {
if (res.headers['content-type'] && (~res.headers['content-type'].indexOf('json'))) {
body = Blast.Bound.JSON.safeParse(body);
}
if (typeof url == 'string') {
if (res.statusCode >= 400) {
error = res.statusCode + ' - ' + res.statusMessage + '\n';
if (arguments.length == 1 && Blast.isBrowser) {
origin = window.location;
}
if (body && typeof body == 'object') {
if (body.code) {
error += ' Body error code: ' + body.code + '\n';
}
this[url_symbol] = Blast.Classes.RURL.parse(url, origin);
} else {
this[url_symbol] = url;
}
});
if (body.message) {
error += ' Body error message: ' + body.message + '\n';
}
}
/**
* Set header
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.2.0
* @version 0.6.2
*
* @param {String} name
* @param {Mixed} value
*/
Request.setMethod(function setHeader(name, value) {
error += 'on ' + config.method + ' ' + String(url) + '\n';
var key;
error = new Error(error);
} else {
error = null;
}
// If `name` is an object,
// set its contents as headers
if (name && typeof name == 'object') {
for (key in name) {
this.setHeader(key, name[key]);
}
callback(error, res, body);
});
});
return;
}
// Listen for request errors
req.on('error', function onRequestError(err) {
callback(err);
});
name = String(name).toLowerCase();
if (body != null) {
req.write(body);
// If only the name is given, return the value
if (arguments.length == 1) {
return this.headers[name];
}
// Initiate the request
req.end();
this.headers[name] = value;
});

@@ -278,18 +288,10 @@

* @since 0.2.0
* @version 0.3.7
* @version 0.6.2
*
* @param {Function} callback
* @return {Pledge}
*/
Request.setMethod(function start(options, callback) {
Request.setMethod(function start() {
var that = this,
options,
url,
req;
var that = this;
if (typeof options == 'function') {
callback = options;
options = {};
}
// Don't start the same request twice

@@ -300,15 +302,11 @@ if (this.original_url) {

// Store the original url
this.original_url = this.url + '';
options.url = this.url;
if (!options.headers) {
options.headers = {};
if (this.get && typeof this.get == 'object') {
this.url.addQuery(this.get);
}
Collection.Object.assign(options.headers, this.headers);
// Date when the request started
this.request_start = Date.now();
// Do the response, follow redirects
this.http_request(options, callback);
return this._make_request();
});

@@ -321,15 +319,19 @@

* @since 0.2.0
* @version 0.2.0
* @version 0.6.2
*
* @param {String|Object} url
* @param {Function} callback
* @param {Object} options
* @param {Function} callback
*/
Blast.fetch = function fetch(url, callback) {
Blast.fetch = function fetch(options, callback) {
var req = new Request();
// Set the url
req.setOptions(options);
// Start the request
return req.http_request(url, callback);
return req.start();
};
// PROTOBLAST START CUT
if (!Blast.isNode) {

@@ -339,11 +341,4 @@ return;

if (Blast.isNW) {
https = nw.require('https');
http = nw.require('http');
zlib = nw.require('zlib');
} else {
https = require('https');
http = require('http');
zlib = require('zlib');
}
require('./request_server.js')(Blast, Collection);
// PROTOBLAST END CUT
};

@@ -46,2 +46,24 @@ module.exports = function BlastURL(Blast, Collection, Bound, Obj) {

/**
* Is the given parameter url-like?
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @return {Boolean}
*/
RURL.setStatic(function isUrl(arg) {
if (!arg) {
return false;
}
if (arg instanceof RURL) {
return true;
}
return RURL.parse(arg).seems_valid;
});
/**
* Parse a URL string

@@ -1162,2 +1184,22 @@ *

/**
* Does this url seem valid?
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @type {Boolean}
*/
RURL.setProperty(function seems_valid() {
if (!this.host && !this.protocol) {
if (this.pathname[0] != '/') {
return false;
}
}
return true;
});
/**
* Return an object for json-drying this object

@@ -1164,0 +1206,0 @@ *

@@ -28,4 +28,7 @@ // Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola

timeout_counter = 0,
idle_counter = 0,
last_idle = 0,
realNextTick,
timeouts = {},
idles = {},
resolved;

@@ -102,6 +105,5 @@

var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};realSetImmediate
var tasksByHandle = {};
var currentlyRunningATask = false;
var doc = global.document;
var realSetImmediate;
var installReadyStateChangeImplementation,

@@ -340,2 +342,125 @@ installMessageChannelImplementation,

Blast.defineGlobal('clearImmediate', clearImmediate);
if (Blast.Globals.requestIdleCallback) {
Blast.requestIdleCallback = Blast.Globals.requestIdleCallback.bind(Blast.Globals);
Blast.cancelIdleCallback = Blast.Globals.cancelIdleCallback.bind(Blast.Globals);
return;
}
/**
* A requestIdleCallback polyfill
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @param {Function} task
* @param {Object} options
*/
Blast.requestIdleCallback = function requestIdleCallback(task, options) {
var request_start = Date.now(),
timeout_time,
grace_period = 0,
did_timeout = false,
lap_start = request_start,
round = 0,
wait = 1,
id = idle_counter++;
if (!options) {
options = {};
}
if (Blast.isBrowser) {
// Browser timeouts minimum is about 4ms
wait = 4;
// Start with a greater grace period
grace_period = 2;
}
// Limit the amount of requests that can be made per second
if (request_start - last_idle < 30) {
wait += 15;
}
last_idle = request_start;
// If a timeout is defined,
// calculate at what time it should have timed out
if (options.timeout) {
timeout_time = options.timeout + request_start;
} else {
timeout_time = Infinity;
}
idles[id] = true;
setTimeout(function didTimeout() {
var now = Date.now(),
elapsed = now - lap_start,
left = grace_period + (wait - elapsed),
remaining;
if (!idles[id]) {
return;
}
// Update the last_idle timestamp
last_idle = now;
round++;
if (left >= 0) {
remaining = 45 + left;
} else if (now >= timeout_time) {
remaining = 0;
did_timeout = true;
} else {
// Increase the grace period up to a maximum of 5ms
// each time we have to retry
if (grace_period < 5) {
grace_period++;
}
// Add the time left (negative value) to 10ms
wait = Math.min(20 - left, 50);
lap_start = now;
setTimeout(didTimeout, wait);
return;
}
task({
didTimeout : did_timeout,
timeRemaining : function timeRemaining() {
return Math.max(0, remaining - (Date.now() - now));
}
});
// Update the last_idle timestamp
last_idle = Date.now();
delete idles[id];
}, wait);
return id;
};
/**
* A cancelIdleCallback polyfill
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.6.2
* @version 0.6.2
*
* @param {Number} id
*/
Blast.cancelIdleCallback = function cancelIdleCallback(id) {
delete idles[id];
};
};

@@ -17,3 +17,3 @@ module.exports = function BlastSorting(Blast, Collection) {

*/
Blast.definePrototype('Array', 'flashsort', function flashsort() {
Blast.definePrototype('Array', function flashsort() {

@@ -20,0 +20,0 @@ var arr = this,

@@ -12,3 +12,3 @@ module.exports = function BlastStringEntities(Blast, Collection) {

*/
Blast.definePrototype('String', 'encodeHTML', function encodeHtml() {
Blast.definePrototype('String', function encodeHTML() {

@@ -52,3 +52,3 @@ var codepoint,

*/
Blast.definePrototype('String', 'decodeHTML', function decodeHtml() {
Blast.definePrototype('String', function decodeHTML() {

@@ -55,0 +55,0 @@ var result,

@@ -585,3 +585,3 @@ module.exports = function BlastString(Blast, Collection, Bound, Obj) {

*/
Blast.definePrototype('String', 'stripTags', function stripTags() {
Blast.definePrototype('String', function stripTags() {
return String.prototype.replace.call(this, /(<([^>]+)>)/ig, '');

@@ -599,3 +599,3 @@ });

*/
Blast.definePrototype('String', 'slug', function slug(separator) {
Blast.definePrototype('String', function slug(separator) {

@@ -650,3 +650,3 @@ var result;

*/
Blast.definePrototype('String', 'dissect', function dissect(open, close) {
Blast.definePrototype('String', function dissect(open, close) {

@@ -730,3 +730,3 @@ var closeLen = close.length,

*/
Blast.definePrototype('String', 'truncate', function truncate(length, word, ellipsis) {
Blast.definePrototype('String', function truncate(length, word, ellipsis) {

@@ -775,3 +775,3 @@ var simpleCut,

*/
Blast.definePrototype('String', 'truncateHTML', function truncateHTML(length, word, ellipsis) {
Blast.definePrototype('String', function truncateHTML(length, word, ellipsis) {

@@ -806,3 +806,3 @@ var tag_length = 0,

*/
Blast.definePrototype('String', 'fixHTML', function fixHTML() {
Blast.definePrototype('String', function fixHTML() {

@@ -873,3 +873,3 @@ var open_tags,

*/
Blast.definePrototype('String', 'replaceAll', function replaceAll(needle, replacement) {
Blast.definePrototype('String', function replaceAll(needle, replacement) {

@@ -906,3 +906,3 @@ var count,

*/
Blast.definePrototype('String', 'capitals', function capitals() {
Blast.definePrototype('String', function capitals() {
return this.replace(/[^A-Z]/g, '').length;

@@ -920,3 +920,3 @@ });

*/
Blast.definePrototype('String', 'count', function count(word) {
Blast.definePrototype('String', function count(word) {

@@ -966,3 +966,3 @@ var result,

*/
Blast.definePrototype('String', 'startsWith', function startsWith(str) {
Blast.definePrototype('String', function startsWith(str) {
return this.slice(0, str.length) == str;

@@ -982,3 +982,3 @@ }, true);

*/
Blast.definePrototype('String', 'startsWithAny', function startsWithAny(strings) {
Blast.definePrototype('String', function startsWithAny(strings) {

@@ -1011,3 +1011,3 @@ var i;

*/
Blast.definePrototype('String', 'endsWith', function endsWith(str) {
Blast.definePrototype('String', function endsWith(str) {

@@ -1032,3 +1032,3 @@ if (str === '') {

*/
Blast.definePrototype('String', 'endsWithAny', function endsWithAny(strings) {
Blast.definePrototype('String', function endsWithAny(strings) {

@@ -1061,3 +1061,3 @@ var i;

*/
Blast.definePrototype('String', 'postfix', function postfix(postfixString) {
Blast.definePrototype('String', function postfix(postfixString) {

@@ -1084,3 +1084,3 @@ var str = ''+this;

*/
Blast.definePrototype('String', 'isHex', function isHex() {
Blast.definePrototype('String', function isHex() {
return !isNaN(Number('0x'+this));

@@ -1098,3 +1098,3 @@ });

*/
Blast.definePrototype('String', 'despace', function despace() {
Blast.definePrototype('String', function despace() {
return this.replace(/ /g, '_');

@@ -1114,3 +1114,3 @@ });

*/
Blast.definePrototype('String', 'multiply', function multiply(number) {
Blast.definePrototype('String', function multiply(number) {

@@ -1141,3 +1141,3 @@ var str = '',

*/
Blast.definePrototype('String', 'isObjectId', function isObjectId() {
Blast.definePrototype('String', function isObjectId() {
return this.length == 24 && Bound.String.isHex(this);

@@ -1157,3 +1157,3 @@ });

*/
Blast.definePrototype('String', 'isHash', function isHash(hashType) {
Blast.definePrototype('String', function isHash(hashType) {

@@ -1195,3 +1195,3 @@ var isHex = Bound.String.isHex(this);

*/
Blast.definePrototype('String', 'numberHash', function hash() {
Blast.definePrototype('String', function numberHash() {

@@ -1223,3 +1223,3 @@ var str = this,

*/
Blast.definePrototype('String', 'checksum', function checksum(start, end) {
Blast.definePrototype('String', function checksum(start, end) {

@@ -1253,3 +1253,3 @@ var crc = -1,

*/
Blast.definePrototype('String', 'fowler', function fowler() {
Blast.definePrototype('String', function fowler() {

@@ -1285,3 +1285,3 @@ var strToByteArray,

*/
Blast.definePrototype('String', 'placeholders', function placeholders() {
Blast.definePrototype('String', function placeholders() {

@@ -1313,3 +1313,3 @@ var regex = /:(\w*)/g,

*/
Blast.definePrototype('String', 'fillPlaceholders', function fillPlaceholders(values, remove_used) {
Blast.definePrototype('String', function fillPlaceholders(values, remove_used) {

@@ -1377,3 +1377,3 @@ var result = ''+this,

*/
Blast.definePrototype('String', 'assignments', function assignments() {
Blast.definePrototype('String', function assignments() {

@@ -1404,3 +1404,3 @@ var pattern = /\{([^{]+?)\}/g,

*/
Blast.definePrototype('String', 'assign', function assign(_values, remove_used) {
Blast.definePrototype('String', function assign(_values, remove_used) {

@@ -1459,3 +1459,3 @@ var pattern,

*/
Blast.definePrototype('String', 'normalizeAcronyms', function normalizeAcronyms() {
Blast.definePrototype('String', function normalizeAcronyms() {

@@ -1566,3 +1566,3 @@ var result = this,

*/
Blast.definePrototype('String', 'score', function score(word, fuzziness) {
Blast.definePrototype('String', function score(word, fuzziness) {

@@ -1666,3 +1666,3 @@ // If the string is equal to the word, perfect match.

*/
Blast.definePrototype('String', 'repeat', function repeat(count) {
Blast.definePrototype('String', function repeat(count) {

@@ -1727,3 +1727,3 @@ var result,

*/
Blast.definePrototype('String', 'padStart', function padStart(target_length, pad_string) {
Blast.definePrototype('String', function padStart(target_length, pad_string) {

@@ -1766,3 +1766,3 @@ // Make sure it's a number

*/
Blast.definePrototype('String', 'padEnd', function padEnd(target_length, pad_string) {
Blast.definePrototype('String', function padEnd(target_length, pad_string) {

@@ -1803,3 +1803,3 @@ // Make sure it's a number

*/
Blast.definePrototype('String', 'isEmptyWhitespace', function isEmptyWhitespace() {
Blast.definePrototype('String', function isEmptyWhitespace() {

@@ -1825,3 +1825,3 @@ var len = this.length,

*/
Blast.definePrototype('String', 'isEmptyWhitespaceHTML', function isEmptyWhitespaceHTML() {
Blast.definePrototype('String', function isEmptyWhitespaceHTML() {

@@ -1828,0 +1828,0 @@ var str;

@@ -66,3 +66,3 @@ module.exports = function BlastSymbol(Blast, Collection, Bound, Obj) {

*/
Blast.definePrototype('Symbol', 'toString', function toString() {
Blast.definePrototype('Symbol', function toString() {
return this.__name;

@@ -69,0 +69,0 @@ }, true);

@@ -34,3 +34,3 @@ module.exports = function BlastWeakMap(Blast, Collection) {

*/
Blast.definePrototype('WeakMap', 'set', function set(obj, val) {
Blast.definePrototype('WeakMap', function set(obj, val) {
var map = this._blastMap(obj);

@@ -53,3 +53,3 @@

*/
Blast.definePrototype('WeakMap', 'get', function get(obj) {
Blast.definePrototype('WeakMap', function get(obj) {
var map = this._blastMap(obj);

@@ -69,3 +69,3 @@ return map[this.id];

*/
Blast.definePrototype('WeakMap', 'has', function has(obj) {
Blast.definePrototype('WeakMap', function has(obj) {
var map = this._blastMap(obj);

@@ -107,3 +107,3 @@

*/
Blast.definePrototype('WeakMap', '_blastMap', function _blastMap(obj) {
Blast.definePrototype('WeakMap', function _blastMap(obj) {

@@ -110,0 +110,0 @@ var map;

{
"name": "protoblast",
"description": "Native object expansion library",
"version": "0.6.1",
"version": "0.6.2",
"author": "Jelle De Loecker <jelle@develry.be>",

@@ -15,3 +15,3 @@ "keywords": [

"dependencies": {
"json-dry" : "~1.0.7"
"json-dry" : "~1.0.8"
},

@@ -18,0 +18,0 @@ "repository": "skerit/protoblast",

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