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.5.7 to 0.5.8

7

CHANGELOG.md

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

## 0.5.8 (2018-07-04)
* Setters & getters defined with `setProperty` should now also get a `super` property
* `Object.flatten(obj, divider, flatten_arrays)` now takes a third argument that enables you to disable flattening arrays
* Upgrade json-dry dependency to v1.0.5
* Added new operators & keywords to the function tokenizer
## 0.5.7 (2018-07-01)

@@ -2,0 +9,0 @@

27

lib/function_inheritance.js

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

* @since 0.1.4
* @version 0.1.4
* @version 0.5.8
*

@@ -1058,2 +1058,4 @@ * @param {Function} constructor Constructor to modify prototype of

var enumerable,
super_desc,
is_getter,
existing,

@@ -1064,3 +1066,2 @@ getter,

config,
proto,
keys,

@@ -1071,3 +1072,2 @@ i;

target = constructor.prototype;
proto = true;
enumerable = false;

@@ -1094,2 +1094,4 @@ } else {

if (typeof getter == 'function') {
is_getter = true;
config = {

@@ -1113,4 +1115,23 @@ get: getter,

target.waitingProperties.push([keys[i], config]);
} else if (is_getter && !super_desc && constructor.super) {
// See if the super constructor already has a descriptor for this
super_desc = Obj.getPropertyDescriptor(constructor.super, keys[i]);
}
if (super_desc) {
// Set the parent getter as the new getter's `super` property
Blast.defineValue(config.get, 'super', super_desc.get);
// Do the same for setter,
// but totally inherit the parent setter if we didn't add one
if (super_desc.set) {
if (config.set) {
Blast.defineValue(config.set, 'super', super_desc.set);
} else {
config.set = super_desc.set;
}
}
}
Object.defineProperty(target, keys[i], config);

@@ -1117,0 +1138,0 @@ }

module.exports = function BlastFunction(Blast, Collection) {
var tokenPatterns,
var token_patterns,
tokenMatches,

@@ -8,10 +8,79 @@ tokenTesters,

haveCombined,
combineError;
combineError,
operators,
keywords;
tokenPatterns = {
keywords = [
'async', 'await',
'break',
'case', 'catch', 'class', 'const', 'continue',
'debugger', 'default', 'delete', 'do',
'else', 'enum', 'export',
'false', 'finally', 'for', 'function',
'if', 'in', 'instanceof',
'let',
'new', 'null',
'return',
'switch',
'this', 'throw', 'true', 'try', 'typeof',
'var', 'void',
'while', 'with',
'yield'
];
operators = {
'>>>=': 'assign_unsigned_right_shift',
'>>=' : 'assign_right_shift',
'<<=' : 'assign_left_shift',
'...' : 'spread',
'|=' : 'assign_bitwise_or',
'^=' : 'assign_bitwise_xor',
'&=' : 'assign_bitwise_and',
'+=' : 'assign_plus',
'-=' : 'assign_minus',
'*=' : 'assign_multiply',
'/=' : 'assign_divide',
'%=' : 'assign_mod',
';' : 'semicolon',
',' : 'comma',
'?' : 'hook',
':' : 'colon',
'||' : 'or',
'&&' : 'and',
'|' : 'bitwise_or',
'^' : 'bitwise_xor',
'&' : 'bitwise_and',
'===' : 'strict_eq',
'==' : 'eq',
'=>' : 'arrow_function',
'=' : 'assign',
'!==' : 'strict_ne',
'!=' : 'ne',
'<<' : 'lsh',
'<=' : 'le',
'<' : 'lt',
'>>>' : 'unsigned_right_shift',
'>>' : 'right_shift',
'>=' : 'ge',
'>' : 'gt',
'++' : 'increment',
'--' : 'decrement',
'**' : 'exponentiation',
'+' : 'plus',
'-' : 'minus',
'*' : 'multiply',
'/' : 'divide',
'%' : 'mod',
'!' : 'not',
'~' : 'bitwise_not',
'.' : 'dot'
};
token_patterns = {
whitespace : /\s+/,
keyword : /\b(?:var|const|let|for|if|else|in|class|function|typeof|return|with|case|break|switch|export|new|while|do|throw|catch|true|false|continue|null|undefined|try)\b/,
keyword : null,
name : /[a-zA-Z_\$][a-zA-Z_\$0-9]*/,
string1 : /"(?:(?:\\\n|\\"|[^"\n]))*?"/,
string2 : /'(?:(?:\\\n|\\'|[^'\n]))*?'/,
string3 : /`(?:(?:\\`|.|[\n\r]))*?`/,
comment1 : /\/\*[\s\S]*?\*\//,

@@ -28,6 +97,7 @@ comment2 : /\/\/.*?\n/,

patternNames = {
string1: 'string',
string2: 'string',
comment1: 'comment',
comment2: 'comment'
string1 : 'string',
string2 : 'string',
string3 : 'string',
comment1 : 'comment',
comment2 : 'comment',
};

@@ -37,7 +107,24 @@

var patternName;
var temp,
name,
key,
i;
token_patterns.keyword = RegExp('\\b(?:' + keywords.join('|') + ')\\b');
temp = '';
for (key in operators) {
if (temp) {
temp += '|';
}
temp += Blast.Bound.RegExp.escape(key);
}
token_patterns.punct = RegExp('(?:' + temp + ')');
try {
// Create the matches
tokenMatches = Collection.RegExp.combine.apply(null, Collection.Object.values(tokenPatterns));
tokenMatches = Collection.RegExp.combine.apply(null, Collection.Object.values(token_patterns));
} catch (err) {

@@ -51,4 +138,4 @@ combineError = err;

for (patternName in tokenPatterns) {
tokenTesters[patternName] = new RegExp('^' + Collection.RegExp.prototype.getPattern.call(tokenPatterns[patternName]) + '$');
for (name in token_patterns) {
tokenTesters[name] = new RegExp('^' + Collection.RegExp.prototype.getPattern.call(token_patterns[name]) + '$');
}

@@ -148,3 +235,3 @@

for (patternName in tokenPatterns) {
for (patternName in token_patterns) {
if (tokenTesters[patternName].test(tokenString)) {

@@ -215,6 +302,12 @@

obj = {
type: Collection.Function.getTokenType(tokens[i]),
value: tokens[i]
type : Collection.Function.getTokenType(tokens[i]),
value : tokens[i],
};
if (obj.type == 'keyword') {
obj.name = obj.value;
} else if (operators[tokens[i]]) {
obj.name = operators[tokens[i]];
}
// Replace the original string with the object

@@ -221,0 +314,0 @@ tokens[i] = obj;

@@ -240,11 +240,29 @@ module.exports = function BlastObject(Blast, Collection, Bound, Obj) {

* @since 0.1.2
* @version 0.1.2
* @version 0.5.8
*
* @param {Object} obj The object to flatten
* @param {String|Array} divider The divider to use (.)
* @param {Boolean} flatten_arrays (true)
*
* @return {Object}
*/
Blast.defineStatic('Object', 'flatten', function flatten(obj, divider, flatten_arrays) {
return flatten_object(obj, divider, 0, flatten_arrays);
});
/**
* Flatten an object
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.1.2
* @version 0.5.8
*
* @param {Object} obj The object to flatten
* @param {String|Array} divider The divider to use (.)
* @param {Number} level
* @param {Boolean} flatten_arrays (true)
*
* @return {Object}
*/
Blast.defineStatic('Object', 'flatten', function flatten(obj, divider, level) {
function flatten_object(obj, divider, level, flatten_arrays) {

@@ -272,2 +290,6 @@ var divider_start,

if (flatten_arrays == null) {
flatten_arrays = true;
}
for (key in obj) {

@@ -278,4 +300,4 @@

if (Obj.isPlainObject(obj[key]) || Array.isArray(obj[key])) {
temp = flatten(obj[key], divider, level + 1);
if (Obj.isPlainObject(obj[key]) || (flatten_arrays && Array.isArray(obj[key]))) {
temp = flatten_object(obj[key], divider, level + 1, flatten_arrays);

@@ -320,3 +342,3 @@ // Inject the keys of the sub-object into the result

return result;
});
}

@@ -323,0 +345,0 @@ /**

4

package.json
{
"name": "protoblast",
"description": "Native object expansion library",
"version": "0.5.7",
"version": "0.5.8",
"author": "Jelle De Loecker <jelle@develry.be>",

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

"dependencies": {
"json-dry" : "~1.0.4"
"json-dry" : "~1.0.5"
},

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

Sorry, the diff of this file is not supported yet

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