Socket
Socket
Sign inDemoInstall

metal

Package Overview
Dependencies
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metal - npm Package Compare versions

Comparing version 2.14.0 to 2.15.0

20

lib/array/array.js
'use strict';
/**
* Set of utilities for array operations
*/
Object.defineProperty(exports, "__esModule", {

@@ -9,4 +13,2 @@ value: true

var _core = require('../core');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -62,3 +64,3 @@

* @param {Array.<*|Array.<*>>} arr Nested array to flatten.
* @param {Array.<*>} opt_output Optional output array.
* @param {Array.<*>=} output Optional output array.
* @return {Array.<*>} Flat array.

@@ -69,4 +71,5 @@ */

key: 'flatten',
value: function flatten(arr, opt_output) {
var output = opt_output || [];
value: function flatten(arr) {
var output = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
for (var i = 0; i < arr.length; i++) {

@@ -119,3 +122,3 @@ if (Array.isArray(arr[i])) {

* @param {number} start The index that should start the slice.
* @param {number=} opt_end The index where the slice should end, not
* @param {number=} end The index where the slice should end, not
* included in the final array. If not given, all elements after the

@@ -128,5 +131,6 @@ * start index will be included.

key: 'slice',
value: function slice(arr, start, opt_end) {
value: function slice(arr, start) {
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length;
var sliced = [];
var end = (0, _core.isDef)(opt_end) ? opt_end : arr.length;
for (var i = start; i < end; i++) {

@@ -133,0 +137,0 @@ sliced.push(arr[i]);

21

lib/async/async.js

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

/*!
/* !
* Polyfill from Google's Closure Library.

@@ -31,7 +31,7 @@ * Copyright 2013 The Closure Library Authors. All Rights Reserved.

* @param {function(this:THIS)} callback
* @param {THIS=} opt_context Object to use as the "this value" when calling
* @param {THIS=} context Object to use as the "this value" when calling
* the provided function.
* @template THIS
*/
async.run = function (callback, opt_context) {
async.run = function (callback, context) {
if (!async.run.workQueueScheduled_) {

@@ -43,3 +43,3 @@ // Nothing is currently scheduled, schedule it now.

async.run.workQueue_.push(new async.run.WorkItem_(callback, opt_context));
async.run.workQueue_.push(new async.run.WorkItem_(callback, context));
};

@@ -100,9 +100,9 @@

* possible.
* @param {SCOPE=} opt_context Object in whose scope to call the listener.
* @param {SCOPE=} context Object in whose scope to call the listener.
* @template SCOPE
*/
async.nextTick = function (callback, opt_context) {
async.nextTick = function (callback, context) {
var cb = callback;
if (opt_context) {
cb = callback.bind(opt_context);
if (context) {
cb = callback.bind(context);
}

@@ -121,2 +121,3 @@ cb = async.nextTick.wrapCallback_(cb);

if (!async.nextTick.setImmediate_) {
// eslint-disable-next-line
async.nextTick.setImmediate_ = async.nextTick.getSetImmediateEmulator_();

@@ -238,6 +239,6 @@ }

*/
async.nextTick.wrapCallback_ = function (opt_returnValue) {
return opt_returnValue;
async.nextTick.wrapCallback_ = function (callback) {
return callback;
};
exports.default = async;

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

* if it's not possible to upgrade the code to use "ref" instead.
* @param {Object=} opt_data Optional object with data to specify more
* @param {Object=} data Optional object with data to specify more
* details, such as:

@@ -92,5 +92,5 @@ * - renderers {Array} the template renderers that should be in

function enableCompatibilityMode() {
var opt_data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
compatibilityModeData_ = opt_data;
compatibilityModeData_ = data;
}

@@ -148,13 +148,16 @@

* @param {string} propertyName Property name to be merged.
* @param {function(*, *):*=} opt_mergeFn Function that receives the merged
* @param {function(*, *):*=} mergeFn Function that receives the merged
* value of the property so far and the next value to be merged to it.
* Should return these two merged together. If not passed the final property
* will be the first truthy value among ancestors.
* @return {Object}
*/
function getStaticProperty(ctor, propertyName, opt_mergeFn) {
function getStaticProperty(ctor, propertyName) {
var mergeFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getFirstTruthy_;
var mergedName = propertyName + '_MERGED';
if (!ctor.hasOwnProperty(mergedName)) {
// eslint-disable-next-line
var merged = ctor.hasOwnProperty(propertyName) ? ctor[propertyName] : null;
if (ctor.__proto__ && !ctor.__proto__.isPrototypeOf(Function)) {
var mergeFn = opt_mergeFn || getFirstTruthy_;
merged = mergeFn(merged, getStaticProperty(ctor.__proto__, propertyName, mergeFn));

@@ -168,19 +171,20 @@ }

/**
* Gets an unique id. If `opt_object` argument is passed, the object is
* Gets an unique id. If `object` argument is passed, the object is
* mutated with an unique id. Consecutive calls with the same object
* reference won't mutate the object again, instead the current object uid
* returns. See {@link UID_PROPERTY}.
* @param {Object=} opt_object Optional object to be mutated with the uid. If
* @param {Object=} object Optional object to be mutated with the uid. If
* not specified this method only returns the uid.
* @param {boolean=} opt_noInheritance Optional flag indicating if this
* @param {boolean=} noInheritance Optional flag indicating if this
* object's uid property can be inherited from parents or not.
* @throws {Error} when invoked to indicate the method should be overridden.
* @return {number}
*/
function getUid(opt_object, opt_noInheritance) {
if (opt_object) {
var id = opt_object[UID_PROPERTY];
if (opt_noInheritance && !opt_object.hasOwnProperty(UID_PROPERTY)) {
function getUid(object, noInheritance) {
if (object) {
var id = object[UID_PROPERTY];
if (noInheritance && !object.hasOwnProperty(UID_PROPERTY)) {
id = null;
}
return id || (opt_object[UID_PROPERTY] = uniqueIdCounter_++);
return id || (object[UID_PROPERTY] = uniqueIdCounter_++);
}

@@ -192,7 +196,7 @@ return uniqueIdCounter_++;

* The identity function. Returns its first argument.
* @param {*=} opt_returnValue The single value that will be returned.
* @param {*=} returnValue The single value that will be returned.
* @return {?} The first argument.
*/
function identityFunction(opt_returnValue) {
return opt_returnValue;
function identityFunction(returnValue) {
return returnValue;
}

@@ -199,0 +203,0 @@

@@ -20,2 +20,5 @@ 'use strict';

var Disposable = function () {
/**
* Disposable constructor
*/
function Disposable() {

@@ -22,0 +25,0 @@ _classCallCheck(this, Disposable);

'use strict';
/**
* Set of utilities for object operations
*/
Object.defineProperty(exports, "__esModule", {

@@ -26,6 +30,14 @@ value: true

value: function mixin(target) {
var key = void 0,
source = void 0;
for (var i = 1; i < arguments.length; i++) {
source = arguments[i];
var key = void 0;
var source = void 0;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
for (var i = 0; i < args.length; i++) {
source = args[i];
// Possible prototype chain leak, breaks 1 metal-dom and
// 1 metal-incremental-dom test if guard-for-in rule is addressed
// eslint-disable-next-line
for (key in source) {

@@ -41,3 +53,3 @@ target[key] = source[key];

* @param {string} name The fully qualified name.
* @param {object=} opt_obj The object within which to look; default is
* @param {object=} scope The object within which to look; default is
* <code>window</code>.

@@ -49,4 +61,5 @@ * @return {?} The value (object or primitive) or, if not found, undefined.

key: 'getObjectByName',
value: function getObjectByName(name, opt_obj) {
var scope = opt_obj || window;
value: function getObjectByName(name) {
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
var parts = name.split('.');

@@ -80,2 +93,4 @@ return parts.reduce(function (part, key) {

* check, including only the keys directly contained by the 2 objects.
* @param {Object} obj1
* @param {Object} obj2
* @return {boolean}

@@ -82,0 +97,0 @@ */

'use strict';
/**
* Set of utilities for string operations
*/
Object.defineProperty(exports, "__esModule", {

@@ -54,7 +58,7 @@ value: true

/**
* Escapes characters in the string that are not safe to use in a RegExp.
* @param {*} str The string to escape. If not a string, it will be casted
* to one.
* @return {string} A RegExp safe, escaped copy of {@code s}.
*/
* Escapes characters in the string that are not safe to use in a RegExp.
* @param {*} str The string to escape. If not a string, it will be casted
* to one.
* @return {string} A RegExp safe, escaped copy of {@code s}.
*/

@@ -64,9 +68,9 @@ }, {

value: function escapeRegex(str) {
return String(str).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1').replace(/\x08/g, '\\x08');
return String(str).replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, '\\$1').replace(/\x08/g, '\\x08'); // eslint-disable-line
}
/**
* Returns a string with at least 64-bits of randomness.
* @return {string} A random string, e.g. sn1s7vb4gcic.
*/
* Returns a string with at least 64-bits of randomness.
* @return {string} A random string, e.g. sn1s7vb4gcic.
*/

@@ -73,0 +77,0 @@ }, {

{
"name": "metal",
"version": "2.14.0",
"version": "2.15.0",
"description": "Core functions from Metal.js, with utilities for dealing with arrays, objects and others.",

@@ -5,0 +5,0 @@ "license": "BSD-3-Clause",

# metal
Core functions from Metal.js, with utilities for dealing with arrays, objects and others.
See [https://metaljs.com/](https://metaljs.com/) for documentation.
'use strict';
import { isDef } from '../core';
/**
* Set of utilities for array operations
*/
class array {

@@ -43,7 +44,6 @@ /**

* @param {Array.<*|Array.<*>>} arr Nested array to flatten.
* @param {Array.<*>} opt_output Optional output array.
* @param {Array.<*>=} output Optional output array.
* @return {Array.<*>} Flat array.
*/
static flatten(arr, opt_output) {
var output = opt_output || [];
static flatten(arr, output = []) {
for (let i = 0; i < arr.length; i++) {

@@ -69,3 +69,3 @@ if (Array.isArray(arr[i])) {

let rv;
if ( (rv = i >= 0) ) {
if ((rv = i >= 0)) {
array.removeAt(arr, i);

@@ -91,3 +91,3 @@ }

* @param {number} start The index that should start the slice.
* @param {number=} opt_end The index where the slice should end, not
* @param {number=} end The index where the slice should end, not
* included in the final array. If not given, all elements after the

@@ -97,5 +97,4 @@ * start index will be included.

*/
static slice(arr, start, opt_end) {
static slice(arr, start, end = arr.length) {
const sliced = [];
const end = isDef(opt_end) ? opt_end : arr.length;
for (let i = start; i < end; i++) {

@@ -102,0 +101,0 @@ sliced.push(arr[i]);

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

/*!
/* !
* Polyfill from Google's Closure Library.

@@ -10,3 +10,2 @@ * Copyright 2013 The Closure Library Authors. All Rights Reserved.

/**

@@ -26,3 +25,2 @@ * Throw an item without interrupting the current execution context. For

/**

@@ -32,7 +30,7 @@ * Fires the provided callback just before the current callstack unwinds, or as

* @param {function(this:THIS)} callback
* @param {THIS=} opt_context Object to use as the "this value" when calling
* @param {THIS=} context Object to use as the "this value" when calling
* the provided function.
* @template THIS
*/
async.run = function(callback, opt_context) {
async.run = function(callback, context) {
if (!async.run.workQueueScheduled_) {

@@ -44,11 +42,8 @@ // Nothing is currently scheduled, schedule it now.

async.run.workQueue_.push(
new async.run.WorkItem_(callback, opt_context));
async.run.workQueue_.push(new async.run.WorkItem_(callback, context));
};
/** @private {boolean} */
async.run.workQueueScheduled_ = false;
/** @private {!Array.<!async.run.WorkItem_>} */

@@ -82,3 +77,2 @@ async.run.workQueue_ = [];

/**

@@ -100,3 +94,2 @@ * @constructor

/**

@@ -108,9 +101,9 @@ * Fires the provided callbacks as soon as possible after the current JS

* possible.
* @param {SCOPE=} opt_context Object in whose scope to call the listener.
* @param {SCOPE=} context Object in whose scope to call the listener.
* @template SCOPE
*/
async.nextTick = function(callback, opt_context) {
async.nextTick = function(callback, context) {
let cb = callback;
if (opt_context) {
cb = callback.bind(opt_context);
if (context) {
cb = callback.bind(context);
}

@@ -129,2 +122,3 @@ cb = async.nextTick.wrapCallback_(cb);

if (!async.nextTick.setImmediate_) {
// eslint-disable-next-line
async.nextTick.setImmediate_ = async.nextTick.getSetImmediateEmulator_();

@@ -135,3 +129,2 @@ }

/**

@@ -144,3 +137,2 @@ * Cache for the setImmediate implementation.

/**

@@ -169,4 +161,8 @@ * Determines the best possible implementation to run a function as soon as

// synchronous postMessage implementation.
if (typeof Channel === 'undefined' && typeof window !== 'undefined' &&
window.postMessage && window.addEventListener) {
if (
typeof Channel === 'undefined' &&
typeof window !== 'undefined' &&
window.postMessage &&
window.addEventListener
) {
/** @constructor */

@@ -199,3 +195,3 @@ Channel = function() {

win.postMessage(message, origin);
}
},
};

@@ -217,3 +213,3 @@ };

tail.next = {
cb: cb
cb: cb,
};

@@ -226,4 +222,6 @@ tail = tail.next;

// onreadystatechange event when inserted into the DOM.
if (typeof document !== 'undefined' && 'onreadystatechange' in
document.createElement('script')) {
if (
typeof document !== 'undefined' &&
'onreadystatechange' in document.createElement('script')
) {
return function(cb) {

@@ -249,3 +247,2 @@ let script = document.createElement('script');

/**

@@ -258,6 +255,6 @@ * Helper function that is overrided to protect callbacks with entry point

*/
async.nextTick.wrapCallback_ = function(opt_returnValue) {
return opt_returnValue;
async.nextTick.wrapCallback_ = function(callback) {
return callback;
};
export default async;

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

export default core;
export { core };
export {core};
export * from './coreNamed';

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

*/
export const UID_PROPERTY = `core_${((Math.random() * 1e9) >>> 0)}`;
export const UID_PROPERTY = `core_${(Math.random() * 1e9) >>> 0}`;

@@ -54,3 +54,3 @@ /**

* if it's not possible to upgrade the code to use "ref" instead.
* @param {Object=} opt_data Optional object with data to specify more
* @param {Object=} data Optional object with data to specify more
* details, such as:

@@ -63,4 +63,4 @@ * - renderers {Array} the template renderers that should be in

*/
export function enableCompatibilityMode(opt_data = {}) {
compatibilityModeData_ = opt_data;
export function enableCompatibilityMode(data = {}) {
compatibilityModeData_ = data;
}

@@ -118,13 +118,20 @@

* @param {string} propertyName Property name to be merged.
* @param {function(*, *):*=} opt_mergeFn Function that receives the merged
* @param {function(*, *):*=} mergeFn Function that receives the merged
* value of the property so far and the next value to be merged to it.
* Should return these two merged together. If not passed the final property
* will be the first truthy value among ancestors.
* @return {Object}
*/
export function getStaticProperty(ctor, propertyName, opt_mergeFn) {
export function getStaticProperty(
ctor,
propertyName,
mergeFn = getFirstTruthy_
) {
const mergedName = propertyName + '_MERGED';
if (!ctor.hasOwnProperty(mergedName)) {
let merged = ctor.hasOwnProperty(propertyName) ? ctor[propertyName] : null;
// eslint-disable-next-line
let merged = ctor.hasOwnProperty(propertyName)
? ctor[propertyName]
: null;
if (ctor.__proto__ && !ctor.__proto__.isPrototypeOf(Function)) {
const mergeFn = opt_mergeFn || getFirstTruthy_;
merged = mergeFn(

@@ -141,19 +148,20 @@ merged,

/**
* Gets an unique id. If `opt_object` argument is passed, the object is
* Gets an unique id. If `object` argument is passed, the object is
* mutated with an unique id. Consecutive calls with the same object
* reference won't mutate the object again, instead the current object uid
* returns. See {@link UID_PROPERTY}.
* @param {Object=} opt_object Optional object to be mutated with the uid. If
* @param {Object=} object Optional object to be mutated with the uid. If
* not specified this method only returns the uid.
* @param {boolean=} opt_noInheritance Optional flag indicating if this
* @param {boolean=} noInheritance Optional flag indicating if this
* object's uid property can be inherited from parents or not.
* @throws {Error} when invoked to indicate the method should be overridden.
* @return {number}
*/
export function getUid(opt_object, opt_noInheritance) {
if (opt_object) {
let id = opt_object[UID_PROPERTY];
if (opt_noInheritance && !opt_object.hasOwnProperty(UID_PROPERTY)) {
export function getUid(object, noInheritance) {
if (object) {
let id = object[UID_PROPERTY];
if (noInheritance && !object.hasOwnProperty(UID_PROPERTY)) {
id = null;
}
return id || (opt_object[UID_PROPERTY] = uniqueIdCounter_++);
return id || (object[UID_PROPERTY] = uniqueIdCounter_++);
}

@@ -165,7 +173,7 @@ return uniqueIdCounter_++;

* The identity function. Returns its first argument.
* @param {*=} opt_returnValue The single value that will be returned.
* @param {*=} returnValue The single value that will be returned.
* @return {?} The first argument.
*/
export function identityFunction(opt_returnValue) {
return opt_returnValue;
export function identityFunction(returnValue) {
return returnValue;
}

@@ -271,3 +279,3 @@

const type = typeof val;
return type === 'object' && val !== null || type === 'function';
return (type === 'object' && val !== null) || type === 'function';
}

@@ -300,6 +308,8 @@

export function isServerSide() {
return typeof process !== 'undefined' &&
return (
typeof process !== 'undefined' &&
typeof process.env !== 'undefined' &&
process.env.NODE_ENV !== 'test' &&
!process.browser;
!process.browser
);
}

@@ -311,3 +321,2 @@

*/
export function nullFunction() {
}
export function nullFunction() {}

@@ -11,2 +11,5 @@ 'use strict';

class Disposable {
/**
* Disposable constructor
*/
constructor() {

@@ -13,0 +16,0 @@ /**

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

export * from './core';
export { array, async, Disposable, object, string };
export {array, async, Disposable, object, string};
export default core;
'use strict';
/**
* Set of utilities for object operations
*/
class object {

@@ -10,6 +13,10 @@ /**

*/
static mixin(target) {
let key, source;
for (let i = 1; i < arguments.length; i++) {
source = arguments[i];
static mixin(target, ...args) {
let key;
let source;
for (let i = 0; i < args.length; i++) {
source = args[i];
// Possible prototype chain leak, breaks 1 metal-dom and
// 1 metal-incremental-dom test if guard-for-in rule is addressed
// eslint-disable-next-line
for (key in source) {

@@ -25,8 +32,7 @@ target[key] = source[key];

* @param {string} name The fully qualified name.
* @param {object=} opt_obj The object within which to look; default is
* @param {object=} scope The object within which to look; default is
* <code>window</code>.
* @return {?} The value (object or primitive) or, if not found, undefined.
*/
static getObjectByName(name, opt_obj) {
const scope = opt_obj || window;
static getObjectByName(name, scope = window) {
const parts = name.split('.');

@@ -55,2 +61,4 @@ return parts.reduce((part, key) => part[key], scope);

* check, including only the keys directly contained by the 2 objects.
* @param {Object} obj1
* @param {Object} obj2
* @return {boolean}

@@ -57,0 +65,0 @@ */

'use strict';
/**
* Set of utilities for string operations
*/
class string {

@@ -32,25 +35,29 @@ /**

static collapseBreakingSpaces(str) {
return str.replace(/[\t\r\n ]+/g, ' ').replace(/^[\t\r\n ]+|[\t\r\n ]+$/g, '');
return str
.replace(/[\t\r\n ]+/g, ' ')
.replace(/^[\t\r\n ]+|[\t\r\n ]+$/g, '');
}
/**
* Escapes characters in the string that are not safe to use in a RegExp.
* @param {*} str The string to escape. If not a string, it will be casted
* to one.
* @return {string} A RegExp safe, escaped copy of {@code s}.
*/
* Escapes characters in the string that are not safe to use in a RegExp.
* @param {*} str The string to escape. If not a string, it will be casted
* to one.
* @return {string} A RegExp safe, escaped copy of {@code s}.
*/
static escapeRegex(str) {
return String(str)
.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1')
.replace(/\x08/g, '\\x08');
.replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, '\\$1')
.replace(/\x08/g, '\\x08'); // eslint-disable-line
}
/**
* Returns a string with at least 64-bits of randomness.
* @return {string} A random string, e.g. sn1s7vb4gcic.
*/
* Returns a string with at least 64-bits of randomness.
* @return {string} A random string, e.g. sn1s7vb4gcic.
*/
static getRandomString() {
const x = 2147483648;
return Math.floor(Math.random() * x).toString(36) +
Math.abs(Math.floor(Math.random() * x) ^ Date.now()).toString(36);
return (
Math.floor(Math.random() * x).toString(36) +
Math.abs(Math.floor(Math.random() * x) ^ Date.now()).toString(36)
);
}

@@ -57,0 +64,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