Socket
Socket
Sign inDemoInstall

melody-runtime

Package Overview
Dependencies
Maintainers
3
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

melody-runtime - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1-github-actions.46

lib/index.esm.js

146

lib/index.js

@@ -19,2 +19,3 @@ 'use strict';

var _isNumber = _interopDefault(require('lodash/isNumber'));
var melodyIdom = require('melody-idom');

@@ -769,2 +770,33 @@ /**

function trim(str, charList) {
var side = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'both';
if (charList === undefined && side === 'both') {
// Use String.prototype.trim() for efficiency
return String(str).trim();
}
if (side !== 'both' && side !== 'left' && side !== 'right') {
throw new Error('Filter "trim". Invalid value ' + side + ' for parameter "side". Valid values are "both", "left", "right".');
}
var strLen = str.length;
var trimStart = 0;
if (side === 'both' || side === 'left') {
while (trimStart < strLen && charList.indexOf(str[trimStart]) !== -1) {
trimStart++;
}
}
var trimEnd = strLen;
if (side === 'both' || side === 'right') {
while (trimEnd > 0 && charList.indexOf(str[trimEnd - 1]) !== -1) {
trimEnd--;
}
}
return str.substr(trimStart, trimEnd - trimStart);
}
var MAX_SAFE_INTEGER = 'MAX_SAFE_INTEGER' in Number ? Number.MAX_SAFE_INTEGER : 9007199254740991;

@@ -870,2 +902,114 @@

var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var AsyncComponent = function () {
function AsyncComponent() {
classCallCheck(this, AsyncComponent);
this.promisedComponent = null;
this._el = null;
this.refs = Object.create(null);
this.props = null;
this.resolvedComponent = null;
this.alreadyUnmounted = false;
this.isLoading = false;
this.loadingError = null;
}
AsyncComponent.prototype.apply = function apply(props) {
var _this = this;
this.props = props;
var promisedComponent = props.promisedComponent;
// if we already have resolved the component, just pass the data forward
if (this.resolvedComponent) {
this.resolvedComponent.apply(this.props.data);
}
// otherwise
if (!this.isLoading) {
this.isLoading = true;
promisedComponent().then(function (_ref) {
var Component = _ref.default;
if (_this.alreadyUnmounted) {
return;
}
_this.resolvedComponent = new Component();
melodyIdom.link(_this, _this.resolvedComponent);
_this.resolvedComponent.el = _this._el;
_this.resolvedComponent.apply(_this.props.data);
}, function (err) {
// fail early
_this.loadingError = err;
melodyIdom.enqueueComponent(_this);
}).catch(function (err) {
// just in case something went wrong while initialising the component
_this.loadingError = err;
melodyIdom.enqueueComponent(_this);
});
if (this.props.delayLoadingAnimation) {
setTimeout(function () {
return melodyIdom.enqueueComponent(_this);
}, this.props.delayLoadingAnimation);
} else {
melodyIdom.enqueueComponent(this);
}
}
};
AsyncComponent.prototype.notify = function notify() {};
AsyncComponent.prototype.componentWillUnmount = function componentWillUnmount() {
this.alreadyUnmounted = true;
};
AsyncComponent.prototype.render = function render() {
if (!this.resolvedComponent) {
if (this.loadingError && this.props.onError) {
this.props.onError(this.loadingError);
} else {
this.props.whileLoading();
}
}
};
createClass(AsyncComponent, [{
key: 'el',
set: function set$$1(el) {
if (this.resolvedComponent) {
this.resolvedComponent.el = el;
}
this._el = el;
return el;
},
get: function get$$1() {
return this.resolvedComponent ? this.resolvedComponent.el : this._el;
}
}]);
return AsyncComponent;
}();
/**

@@ -887,2 +1031,3 @@ * Copyright 2017 trivago N.V.

exports.AsyncComponent = AsyncComponent;
exports.createSubContext = createSubContext;

@@ -903,2 +1048,3 @@ exports.batch = batch;

exports.strtotime = strtotime;
exports.trim = trim;
exports.random = random;

@@ -905,0 +1051,0 @@ exports.min = min;

13

package.json
{
"name": "melody-runtime",
"version": "1.1.0",
"version": "1.1.1-github-actions.46+ef996b4",
"description": "",
"main": "./lib/index.js",
"jsnext:main": "./src/index.js",
"jsnext:main": "./lib/index.esm.js",
"scripts": {
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js -o lib/index.js"
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
},

@@ -15,5 +15,6 @@ "author": "",

},
"devDependencies": {
"rollup-plugin-babel": "^2.6.1"
}
"peerDependencies": {
"melody-idom": "^1.2.0"
},
"gitHead": "ef996b419d24a00a5f204de24274a121ef3af27e"
}

@@ -488,3 +488,3 @@ /**

// Plain Math.round doesn't just truncate
number = Math.round(number - number % 1);
number = Math.round(number - (number % 1));
prefix = number < 0 ? '-' : positivePrefix;

@@ -965,1 +965,34 @@ value =

}
export function trim(str, charList, side = 'both') {
if (charList === undefined && side === 'both') {
// Use String.prototype.trim() for efficiency
return String(str).trim();
}
if (side !== 'both' && side !== 'left' && side !== 'right') {
throw new Error(
'Filter "trim". Invalid value ' +
side +
' for parameter "side". Valid values are "both", "left", "right".'
);
}
const strLen = str.length;
let trimStart = 0;
if (side === 'both' || side === 'left') {
while (trimStart < strLen && charList.indexOf(str[trimStart]) !== -1) {
trimStart++;
}
}
let trimEnd = strLen;
if (side === 'both' || side === 'right') {
while (trimEnd > 0 && charList.indexOf(str[trimEnd - 1]) !== -1) {
trimEnd--;
}
}
return str.substr(trimStart, trimEnd - trimStart);
}

@@ -32,4 +32,8 @@ /**

strtotime,
trim,
} from './filters';
export { random, min, max, cycle, attribute } from './functions';
export { isEmpty, inheritBlocks } from './helpers';
import AsyncComponent from './async';
export { AsyncComponent };
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