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.3.1 to 0.3.2

14

CHANGELOG.md

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

## 0.3.2 (2016-10-04)
* `asyncLoop` functions (like Function.while) will now execute test
and task function in the same tick, in stead of first checking
the test, then doing the task on the next tick
* `Object.checksum` no longer skips undefined values in objects
* fix: child classes with a different namespace than the parent
are now actually stored in that namespace
* `String#decodeHTML()` should now handle hexadecimal entities properly
* Make sure an Object has the `hasOwnProperty` method before using it in JSON-Dry
* `Object.checksum` should also checksumize RegExps correctly
* `RegExp.interpret` now also accepts flags as second parameter
* Decompress HTML entities on-the-fly
## 0.3.1 (2016-07-02)

@@ -2,0 +16,0 @@

20

lib/function_flow.js

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

* @since 0.1.4
* @version 0.1.4
* @version 0.3.2
*

@@ -629,4 +629,4 @@ * @param {Boolean} atleastOnce Should the taskFnc run at least once?

if (isFnc) {
if (matchValue == !!testFnc()) {
Blast.setImmediate(function doAsyncTask() {
Blast.setImmediate(function doAsyncTask() {
if (matchValue == !!testFnc()) {
try {

@@ -637,8 +637,6 @@ taskFnc(handler);

}
});
} else {
callback();
}
} else {
} else {
callback();
}
});
}

@@ -969,3 +967,5 @@ };

*
* @param {Function} fnc
* @param {Function} fnc Function to throttle
* @param {Number} ms Minimum time to wait between executions
* @param {Boolean} immediate If true, execute the first execution immediately
*

@@ -972,0 +972,0 @@ * @return {Function}

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

* @since 0.1.3
* @version 0.2.0
* @version 0.3.2
*

@@ -105,3 +105,4 @@ * @param {String|Function|Array} _parent Parent class to inherit from

var parentConstructor = _parent,
var parent_namespace,
parentConstructor = _parent,
newConstructor = _newConstructor,

@@ -167,3 +168,3 @@ targetPath,

// The namespace is what's left over
namespace = temp.join('.');
parent_namespace = temp.join('.');
} else {

@@ -175,3 +176,3 @@ path = name;

if (typeof Obj.path(Blast.Classes, path) !== 'function' && typeof Obj.path(Blast.Globals, path) !== 'function') {
Blast.once({type: 'extended', descendant: name, namespace: namespace}, function whenClassAvailable() {
Blast.once({type: 'extended', descendant: name, namespace: parent_namespace}, function whenClassAvailable() {

@@ -178,0 +179,0 @@ var oldProto = newConstructor.prototype,

@@ -96,3 +96,3 @@ /**

* @since 0.1.4
* @version 0.2.0
* @version 0.3.2
*

@@ -296,7 +296,9 @@ * @return {Function}

} else {
for (k in value) {
if (value.hasOwnProperty(k)) {
v = dryReplacer(value, k, value[k]);
if (v) {
partial.push(quote(k) + ':' + v);
if (typeof value.hasOwnProperty == 'function') {
for (k in value) {
if (value.hasOwnProperty(k)) {
v = dryReplacer(value, k, value[k]);
if (v) {
partial.push(quote(k) + ':' + v);
}
}

@@ -585,6 +587,7 @@ }

* @since 0.1.6
* @version 0.2.0
* @version 0.3.2
*
* @param {Object} obj
* @param {String} custom_method Custom method to use if available
* @param {Array} extra_args Extra arguments for the custom method
* @param {WeakMap} wm

@@ -594,5 +597,6 @@ *

*/
Blast.defineStatic('JSON', 'clone', function clone(obj, custom_method, wm) {
Blast.defineStatic('JSON', 'clone', function clone(obj, custom_method, extra_args, wm) {
var nameType,
var custom_args,
nameType,
entry,

@@ -606,2 +610,10 @@ split,

if (custom_method instanceof WeakMap) {
wm = custom_method;
custom_method = null;
} else if (!Array.isArray(extra_args)) {
wm = extra_args;
extra_args = null;
}
if (wm == null) {

@@ -618,2 +630,6 @@ wm = new WeakMap();

if (custom_method) {
custom_args = [wm].concat(extra_args);
}
keys = Object.keys(obj);

@@ -640,3 +656,3 @@ len = keys.length;

if (custom_method && entry[custom_method]) {
target[keys[i]] = entry[custom_method](wm);
target[keys[i]] = entry[custom_method].apply(entry, custom_args);
} else if (driers[nameType] != null) {

@@ -643,0 +659,0 @@ // Look for a registered drier function

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

* @since 0.1.3
* @version 0.2.0
* @version 0.3.2
*

@@ -1186,3 +1186,3 @@ * @param {Object|Array} obj

if (type == 'string') {
return 'S' + obj.length + '-' + Blast.Bound.String.checksum(obj);
return 'S' + obj.length + '-' + Blast.Bound.String.checksum(obj).toString(36);
} else if (type == 'number') {

@@ -1196,2 +1196,4 @@ return 'N' + obj;

return 'L';
} else if (obj.constructor && obj.constructor.name == 'RegExp') {
return 'R' + Blast.Bound.String.checksum(''+obj).toString(36);
}

@@ -1225,7 +1227,2 @@

// Skip undefined keys
if (typeof val == 'undefined') {
continue;
}
counter++;

@@ -1235,4 +1232,4 @@

// Normalize non-falsy values
if (val) {
// Cast object instances of primitives to strings

@@ -1244,19 +1241,14 @@ if (Blast.Bound.Object.isPrimitiveObject(val)) {

if ((idx = seen.indexOf(val)) == -1) {
stemp = seen.slice(0);
stemp.push(val);
temp += checksum(val, stemp);
seen.push(val);
val = checksum(val, seen);
} else {
temp += 'R' + idx;
val = 'R' + idx;
}
} else {
temp += val;
}
}
} else {
temp += key + ':' + val;
}
temp += key + ':' + val;
}
// The length is the first part of the checksum,
// for arrays this is very important as undefineds count
// The length is the first part of the checksum
if (result == 'A') {

@@ -1269,3 +1261,3 @@ counter = names.length;

// Now create another checksum
result += ~~(temp.length/counter) + '-' + Blast.Bound.String.checksum(temp);
result += temp.length.toString(36) + Blast.Bound.String.checksum(temp).toString(36);

@@ -1272,0 +1264,0 @@ return result;

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

* @since 0.1.2
* @version 0.1.2
* @version 0.3.2
*
* @param {String} pattern
* @param {String} flags
*
* @return {RegExp}
*/
Blast.defineStatic('RegExp', 'interpret', function interpret(pattern) {
Blast.defineStatic('RegExp', 'interpret', function interpret(pattern, flags) {

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

// The input contains modifiers, use them
return new RegExp(split[1], split[2]);
return new RegExp(split[1], flags || split[2]);
} else {
// There are no delimiters
return new RegExp(pattern);
return new RegExp(pattern, flags);
}

@@ -42,0 +43,0 @@ });

@@ -8,10 +8,23 @@ module.exports = function BlastStringEntities(Blast, Collection) {

// Uncompress the base charmap
charMap = JSON.parse(Collection.String.decompressFromBase64(require('./string_compressed_entities.js')));
/**
* Populate HTMLEntities variable with entities
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.3.2
* @version 0.3.2
*
* @param {String} character The single character to encode
*
* @return {String} The encoded char
*/
function loadEntities() {
// Uncompress the base charmap
charMap = JSON.parse(Collection.String.decompressFromBase64(require('./string_compressed_entities.js')));
HTMLEntities = {};
HTMLEntities = {};
for (key in charMap) {
for (i = 0; i < charMap[key].length; i++) {
HTMLEntities[charMap[key][i]] = key;
for (key in charMap) {
for (i = 0; i < charMap[key].length; i++) {
HTMLEntities[charMap[key][i]] = key;
}
}

@@ -53,3 +66,3 @@ }

* @since 0.1.2
* @version 0.1.2
* @version 0.3.2
*

@@ -63,9 +76,19 @@ * @return {String} The decoded string

// Decode numeric escapes
result = this.replace(/&#(x?)(\d+);/g, function(match, p1, code) {
result = this.replace(/&#(\d+);/g, function(match, code) {
return String.fromCharCode(code);
});
// Decode hexadecimal escapes
result = result.replace(/&#x([0-9a-zA-Z]+);/g, function(match, code) {
return String.fromCharCode(parseInt(code, 16));
});
// Decode named escapes
result = result.replace(/&(\w+);/g, function(match, name) {
// Load the entities on-the-fly
if (HTMLEntities == null) {
loadEntities();
}
if (HTMLEntities[name]) {

@@ -72,0 +95,0 @@ return HTMLEntities[name];

{
"name": "protoblast",
"description": "Add useful methods to native objects",
"version": "0.3.1",
"description": "Native object expansion library",
"version": "0.3.2",
"author": "Jelle De Loecker <jelle@develry.be>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -12,3 +12,3 @@ var assert = require('assert'),

it('should return the source code representation of the string', function() {
assert.strictEqual('(new String("TEST"))', 'TEST'.toSource());
assert.strictEqual('TEST'.toSource(), '(new String("TEST"))');
});

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

it('should take 1 argument', function() {
assert.strictEqual(1, String.prototype.codePointAt.length);
assert.strictEqual(String.prototype.codePointAt.length, 1);
});

@@ -26,0 +26,0 @@

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