Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.2.0-commit.e725f50a to 1.2.0-f61c830.4

LICENSE

146

lib/index.esm.js

@@ -13,2 +13,3 @@ import _isString from 'lodash/isString';

import _isNumber from 'lodash/isNumber';
import { enqueueComponent, link } from 'melody-idom';

@@ -763,2 +764,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;

@@ -864,2 +896,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();
link(_this, _this.resolvedComponent);
_this.resolvedComponent.el = _this._el;
_this.resolvedComponent.apply(_this.props.data);
}, function (err) {
// fail early
_this.loadingError = err;
enqueueComponent(_this);
}).catch(function (err) {
// just in case something went wrong while initialising the component
_this.loadingError = err;
enqueueComponent(_this);
});
if (this.props.delayLoadingAnimation) {
setTimeout(function () {
return enqueueComponent(_this);
}, this.props.delayLoadingAnimation);
} else {
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;
}();
/**

@@ -881,2 +1025,2 @@ * Copyright 2017 trivago N.V.

export { createSubContext, batch, attrs, styles, classes, merge, replace, reverse, round, striptags, number_format, format, title, url_encode, strtotime, random, min, max, cycle, attribute, isEmpty, inheritBlocks };
export { AsyncComponent, createSubContext, batch, attrs, styles, classes, merge, replace, reverse, round, striptags, number_format, format, title, url_encode, strtotime, trim, random, min, max, cycle, attribute, isEmpty, inheritBlocks };

906

lib/index.js

@@ -1,905 +0,1 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _isString = _interopDefault(require('lodash/isString'));
var _floor = _interopDefault(require('lodash/floor'));
var _ceil = _interopDefault(require('lodash/ceil'));
var _round = _interopDefault(require('lodash/round'));
var _isObject = _interopDefault(require('lodash/isObject'));
var _isFunction = _interopDefault(require('lodash/isFunction'));
var _upperFirst = _interopDefault(require('lodash/upperFirst'));
var _values = _interopDefault(require('lodash/values'));
var _max = _interopDefault(require('lodash/max'));
var _min = _interopDefault(require('lodash/min'));
var _random = _interopDefault(require('lodash/random'));
var _isNumber = _interopDefault(require('lodash/isNumber'));
/**
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Creates a subcontext for a given context and assigns custom values to it.
* @param parent The parent context
* @param customValues Any custom values that should be assigned to the child context
* @returns A new child context
*/
function createSubContext(parent, customValues) {
var subContext = Object.create(parent);
if (customValues) {
Object.assign(subContext, customValues);
}
return subContext;
}
function batch(items, groupSize) {
var missing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var batchedResult = [],
len = items.length;
for (var i = 0; i < len; i += groupSize) {
var _batch = [];
for (var j = 0; j < groupSize; j++) {
_batch[_batch.length] = i + j < len ? items[i + j] : missing;
}
batchedResult[batchedResult.length] = _batch;
}
return batchedResult;
}
function attrs(attrMap) {
var attrArray = [];
for (var attr in attrMap) {
if (!attrMap.hasOwnProperty(attr)) {
continue;
}
var value = attrMap[attr];
attrArray.push(attr, value === false || value === null || value === 0 || value === '' ? undefined : value);
}
return attrArray;
}
function styles(declarationsMap) {
var declarations = '';
var keys = Object.keys(declarationsMap);
for (var i = 0; i < keys.length; i++) {
var value = declarationsMap[keys[i]];
if (typeof value === 'string' && value !== '' || typeof value === 'number' && !isNaN(value)) {
declarations += keys[i] + ':' + value + ';';
}
}
return declarations;
}
function classes(classMap) {
var classArray = [];
for (var cla in classMap) {
if (!classMap.hasOwnProperty(cla)) {
continue;
}
if (cla === 'base') {
classArray.push(classMap[cla]);
} else if (classMap[cla]) {
classArray.push(cla);
}
}
return classArray.join(' ');
}
function merge(initial, additions) {
if (Array.isArray(initial) && Array.isArray(additions)) {
return [].concat(initial, additions);
}
return Object.assign({}, initial, additions);
}
function replace(input, replacements) {
var result = input;
for (var search in replacements) {
if (replacements.hasOwnProperty(search)) {
result = result.replace(search, replacements[search]);
}
}
return result;
}
function reverse(iterable) {
if (Array.isArray(iterable)) {
var resArray = [];
for (var i = iterable.length - 1; i >= 0; i--) {
resArray[resArray.length] = iterable[i];
}
return resArray;
} else if (_isString(iterable)) {
var resString = '';
for (var _i = iterable.length - 1; _i >= 0; _i--) {
resString += iterable[_i];
}
return resString;
} else {
// JavaScript isn't PHP. The order in which properties are added to
// an object may or may not be relevant when iterating over the values in
// an object.
// Thus, we don't support that kind of usage.
return iterable;
}
}
function round(num) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'common';
switch (method) {
case 'ceil':
return _ceil(num, precision);
case 'floor':
return _floor(num, precision);
case 'common':
default:
return _round(num, precision);
}
}
function striptags(input) {
// discuss at: http://phpjs.org/functions/strip_tags/
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Luke Godfrey
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// input by: Pul
// input by: Alex
// input by: Marc Palau
// input by: Brett Zamir (http://brett-zamir.me)
// input by: Bobby Drake
// input by: Evertjan Garretsen
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Onno Marsman
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Eric Nagel
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Tomasz Wesolowski
// revised by: Rafał Kukawski (http://blog.kukawski.pl/)
// example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>');
// returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
// example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
// returns 2: '<p>Kevin van Zonneveld</p>'
// example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
// returns 3: "<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>"
// example 4: strip_tags('1 < 5 5 > 1');
// returns 4: '1 < 5 5 > 1'
// example 5: strip_tags('1 <br/> 1');
// returns 5: '1 1'
// example 6: strip_tags('1 <br/> 1', '<br>');
// returns 6: '1 <br/> 1'
// example 7: strip_tags('1 <br/> 1', '<br><br/>');
// returns 7: '1 <br/> 1'
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
return input.replace(commentsAndPhpTags, '').replace(tags, '');
}
function toFixedFix(n, prec) {
var k = Math.pow(10, prec);
return '' + (Math.round(n * k) / k).toFixed(prec);
}
/**
* Filters: number_format
* @param number
* @param decimals
* @param dec_point
* @param thousands_sep
* @returns {string}
*/
function number_format(numberParam, decimals, dec_point, thousands_sep) {
// discuss at: http://phpjs.org/functions/number_format/
// original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: davook
// improved by: Brett Zamir (http://brett-zamir.me)
// improved by: Brett Zamir (http://brett-zamir.me)
// improved by: Theriault
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Michael White (http://getsprink.com)
// bugfixed by: Benjamin Lupton
// bugfixed by: Allan Jensen (http://www.winternet.no)
// bugfixed by: Howard Yeend
// bugfixed by: Diogo Resende
// bugfixed by: Rival
// bugfixed by: Brett Zamir (http://brett-zamir.me)
// revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// revised by: Luke Smith (http://lucassmith.name)
// input by: Kheang Hok Chin (http://www.distantia.ca/)
// input by: Jay Klehr
// input by: Amir Habibi (http://www.residence-mixte.com/)
// input by: Amirouche
var number = (numberParam + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = typeof thousands_sep === 'undefined' ? ',' : thousands_sep,
dec = typeof dec_point === 'undefined' ? '.' : dec_point,
s;
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
}
function format() {
for (var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++) {
a[_key] = arguments[_key];
}
// discuss at: http://phpjs.org/functions/sprintf/
// original by: Ash Searle (http://hexmen.com/blog/)
// improved by: Michael White (http://getsprink.com)
// improved by: Jack
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Dj
// improved by: Allidylls
// input by: Paulo Freitas
// input by: Brett Zamir (http://brett-zamir.me)
// example 1: sprintf("%01.2f", 123.1);
// returns 1: 123.10
// example 2: sprintf("[%10s]", 'monkey');
// returns 2: '[ monkey]'
// example 3: sprintf("[%'#10s]", 'monkey');
// returns 3: '[####monkey]'
// example 4: sprintf("%d", 123456789012345);
// returns 4: '123456789012345'
// example 5: sprintf('%-03s', 'E');
// returns 5: 'E00'
var regex = /%%|%(\d+\$)?([\-+\'#0 ]*)(\*\d+\$|\*|\d+)?(?:\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g;
var i = 0;
var format = a[i++];
// pad()
var pad = function pad(str, len) {
var chr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' ';
var leftJustify = arguments[3];
var padding = str.length >= len ? '' : new Array(1 + len - str.length >>> 0).join(chr);
return leftJustify ? str + padding : padding + str;
};
// justify()
var justify = function justify(value, prefix, leftJustify, minWidth, zeroPad, customPadChar) {
var diff = minWidth - value.length;
if (diff > 0) {
if (leftJustify || !zeroPad) {
return pad(value, minWidth, customPadChar, leftJustify);
} else {
return value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
}
}
return value;
};
// formatBaseX()
var formatBaseX = function formatBaseX(n, base, prefixParam, leftJustify, minWidth, precision, zeroPad) {
// Note: casts negative numbers to positive ones
var number = n >>> 0;
var prefix = prefixParam && number && {
'2': '0b',
'8': '0',
'16': '0x'
}[base] || '';
var value = prefix + pad(number.toString(base), precision || 0, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
};
// formatString()
var formatString = function formatString(valueParam, leftJustify, minWidth, precision, zeroPad, customPadChar) {
var value = valueParam;
if (precision !== null && precision !== undefined) {
value = value.slice(0, precision);
}
return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar);
};
// doFormat()
var doFormat = function doFormat(substring, valueIndex, flags, minWidthParam, precisionParam, type) {
var number, prefix, method, textTransform, value;
if (substring === '%%') {
return '%';
}
// parse flags
var leftJustify = false;
var positivePrefix = '';
var zeroPad = false;
var prefixBaseX = false;
var customPadChar = ' ';
var flagsl = flags.length;
var j;
for (j = 0; flags && j < flagsl; j++) {
switch (flags.charAt(j)) {
case ' ':
positivePrefix = ' ';
break;
case '+':
positivePrefix = '+';
break;
case '-':
leftJustify = true;
break;
case "'":
customPadChar = flags.charAt(j + 1);
break;
case '0':
zeroPad = true;
customPadChar = '0';
break;
case '#':
prefixBaseX = true;
break;
}
}
// parameters may be null, undefined, empty-string or real valued
// we want to ignore null, undefined and empty-string values
var minWidth = minWidthParam;
if (!minWidth) {
minWidth = 0;
} else if (minWidth === '*') {
minWidth = +a[i++];
} else if (minWidth.charAt(0) === '*') {
minWidth = +a[minWidth.slice(1, -1)];
} else {
minWidth = +minWidth;
}
// Note: undocumented perl feature:
if (minWidth < 0) {
minWidth = -minWidth;
leftJustify = true;
}
if (!isFinite(minWidth)) {
throw new Error('sprintf: (minimum-)width must be finite');
}
var precision = precisionParam;
if (!precision) {
precision = 'fFeE'.indexOf(type) > -1 ? 6 : type === 'd' ? 0 : undefined;
} else if (precision === '*') {
precision = +a[i++];
} else if (precision.charAt(0) === '*') {
precision = +a[precision.slice(1, -1)];
} else {
precision = +precision;
}
// grab value using valueIndex if required?
value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
switch (type) {
case 's':
return formatString(String(value), leftJustify, minWidth, precision, zeroPad, customPadChar);
case 'c':
return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
case 'b':
return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'o':
return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'x':
return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'X':
return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase();
case 'u':
return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'i':
case 'd':
number = +value || 0;
// Plain Math.round doesn't just truncate
number = Math.round(number - number % 1);
prefix = number < 0 ? '-' : positivePrefix;
value = prefix + pad(String(Math.abs(number)), precision, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
case 'e':
case 'E':
case 'f': // Should handle locales (as per setlocale)
case 'F':
case 'g':
case 'G':
number = +value;
prefix = number < 0 ? '-' : positivePrefix;
method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
value = prefix + Math.abs(number)[method](precision);
return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
default:
return substring;
}
};
return format.replace(regex, doFormat);
}
function title(input) {
var res = '',
ucNext = true;
for (var i = 0, len = input.length; i < len; i++) {
var c = input[i];
if (c === '\n' || c === ' ' || c === '\t') {
ucNext = true;
res += c;
} else if (ucNext) {
res += c.toUpperCase();
ucNext = false;
} else {
res += c;
}
}
return res;
}
function url_encode(input) {
if (_isString(input)) {
return encodeURIComponent(input);
}
var parts = [];
for (var key in input) {
if (input.hasOwnProperty(key)) {
parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(input[key]));
}
}
return parts.join('&');
}
function strtotime(input, now) {
// discuss at: http://phpjs.org/functions/strtotime/
// version: 1109.2016
// original by: Caio Ariede (http://caioariede.com)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Caio Ariede (http://caioariede.com)
// improved by: A. Matías Quezada (http://amatiasq.com)
// improved by: preuter
// improved by: Brett Zamir (http://brett-zamir.me)
// improved by: Mirko Faber
// input by: David
// bugfixed by: Wagner B. Soares
// bugfixed by: Artur Tchernychev
// bugfixed by: Stephan Bösch-Plepelits (http://github.com/plepe)
// note: Examples all have a fixed timestamp to prevent tests to fail because of variable time(zones)
// example 1: strtotime('+1 day', 1129633200);
// returns 1: 1129719600
// example 2: strtotime('+1 week 2 days 4 hours 2 seconds', 1129633200);
// returns 2: 1130425202
// example 3: strtotime('last month', 1129633200);
// returns 3: 1127041200
// example 4: strtotime('2009-05-04 08:30:00 GMT');
// returns 4: 1241425800
// example 5: strtotime('2009-05-04 08:30:00+00');
// returns 5: 1241425800
// example 6: strtotime('2009-05-04 08:30:00+02:00');
// returns 6: 1241418600
// example 7: strtotime('2009-05-04T08:30:00Z');
// returns 7: 1241425800
var parsed,
match,
today,
year,
date,
days,
ranges,
len,
times,
regex,
i,
fail = false;
if (!input) {
return fail;
}
// Unecessary spaces
var text = input.replace(/^\s+|\s+$/g, '').replace(/\s{2,}/g, ' ').replace(/[\t\r\n]/g, '').toLowerCase();
// in contrast to php, js Date.parse function interprets:
// dates given as yyyy-mm-dd as in timezone: UTC,
// dates with "." or "-" as MDY instead of DMY
// dates with two-digit years differently
// etc...etc...
// ...therefore we manually parse lots of common date formats
match = text.match(/^(\d{1,4})([\-\.\/\:])(\d{1,2})([\-\.\/\:])(\d{1,4})(?:\s(\d{1,2}):(\d{2})?:?(\d{2})?)?(?:\s([A-Z]+)?)?$/);
if (match && match[2] === match[4]) {
if (match[1] > 1901) {
switch (match[2]) {
case '-':
{
// YYYY-M-D
if (match[3] > 12 || match[5] > 31) {
return fail;
}
return new Date(match[1], parseInt(match[3], 10) - 1, match[5], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
case '.':
{
// YYYY.M.D is not parsed by strtotime()
return fail;
}
case '/':
{
// YYYY/M/D
if (match[3] > 12 || match[5] > 31) {
return fail;
}
return new Date(match[1], parseInt(match[3], 10) - 1, match[5], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
}
} else if (match[5] > 1901) {
switch (match[2]) {
case '-':
{
// D-M-YYYY
if (match[3] > 12 || match[1] > 31) {
return fail;
}
return new Date(match[5], parseInt(match[3], 10) - 1, match[1], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
case '.':
{
// D.M.YYYY
if (match[3] > 12 || match[1] > 31) {
return fail;
}
return new Date(match[5], parseInt(match[3], 10) - 1, match[1], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
case '/':
{
// M/D/YYYY
if (match[1] > 12 || match[3] > 31) {
return fail;
}
return new Date(match[5], parseInt(match[1], 10) - 1, match[3], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
}
} else {
switch (match[2]) {
case '-':
{
// YY-M-D
if (match[3] > 12 || match[5] > 31 || match[1] < 70 && match[1] > 38) {
return fail;
}
year = match[1] >= 0 && match[1] <= 38 ? +match[1] + 2000 : match[1];
return new Date(year, parseInt(match[3], 10) - 1, match[5], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
case '.':
{
// D.M.YY or H.MM.SS
if (match[5] >= 70) {
// D.M.YY
if (match[3] > 12 || match[1] > 31) {
return fail;
}
return new Date(match[5], parseInt(match[3], 10) - 1, match[1], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
if (match[5] < 60 && !match[6]) {
// H.MM.SS
if (match[1] > 23 || match[3] > 59) {
return fail;
}
today = new Date();
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), match[1] || 0, match[3] || 0, match[5] || 0, match[9] || 0) / 1000;
}
// invalid format, cannot be parsed
return fail;
}
case '/':
{
// M/D/YY
if (match[1] > 12 || match[3] > 31 || match[5] < 70 && match[5] > 38) {
return fail;
}
year = match[5] >= 0 && match[5] <= 38 ? +match[5] + 2000 : match[5];
return new Date(year, parseInt(match[1], 10) - 1, match[3], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000;
}
case ':':
{
// HH:MM:SS
if (match[1] > 23 || match[3] > 59 || match[5] > 59) {
return fail;
}
today = new Date();
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), match[1] || 0, match[3] || 0, match[5] || 0) / 1000;
}
}
}
}
// other formats and "now" should be parsed by Date.parse()
if (text === 'now') {
return now === null || isNaN(now) ? new Date().getTime() / 1000 | 0 : now | 0;
}
if (!isNaN(parsed = Date.parse(text))) {
return parsed / 1000 | 0;
}
// Browsers != Chrome have problems parsing ISO 8601 date strings, as they do
// not accept lower case characters, space, or shortened time zones.
// Therefore, fix these problems and try again.
// Examples:
// 2015-04-15 20:33:59+02
// 2015-04-15 20:33:59z
// 2015-04-15t20:33:59+02:00
match = text.match(/^([0-9]{4}-[0-9]{2}-[0-9]{2})[ t]([0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?)([\+-][0-9]{2}(:[0-9]{2})?|z)/);
if (match) {
// fix time zone information
if (match[4] == 'z') {
match[4] = 'Z';
} else if (match[4].match(/^([\+-][0-9]{2})$/)) {
match[4] = match[4] + ':00';
}
if (!isNaN(parsed = Date.parse(match[1] + 'T' + match[2] + match[4]))) {
return parsed / 1000 | 0;
}
}
date = now ? new Date(now * 1000) : new Date();
days = {
sun: 0,
mon: 1,
tue: 2,
wed: 3,
thu: 4,
fri: 5,
sat: 6
};
ranges = {
yea: 'FullYear',
mon: 'Month',
day: 'Date',
hou: 'Hours',
min: 'Minutes',
sec: 'Seconds'
};
function lastNext(type, range, modifier) {
var diff = void 0;
var day = days[range];
if (typeof day !== 'undefined') {
diff = day - date.getDay();
if (diff === 0) {
diff = 7 * modifier;
} else if (diff > 0 && type === 'last') {
diff -= 7;
} else if (diff < 0 && type === 'next') {
diff += 7;
}
date.setDate(date.getDate() + diff);
}
}
function process(val) {
var splt = val.split(' '),
// Todo: Reconcile this with regex using \s, taking into account browser issues with split and regexes
type = splt[0],
range = splt[1].substring(0, 3),
typeIsNumber = /\d+/.test(type),
ago = splt[2] === 'ago',
num = (type === 'last' ? -1 : 1) * (ago ? -1 : 1);
if (typeIsNumber) {
num *= parseInt(type, 10);
}
if (ranges.hasOwnProperty(range) && !splt[1].match(/^mon(day|\.)?$/i)) {
return date['set' + ranges[range]](date['get' + ranges[range]]() + num);
}
if (range === 'wee') {
return date.setDate(date.getDate() + num * 7);
}
if (type === 'next' || type === 'last') {
lastNext(type, range, num);
} else if (!typeIsNumber) {
return false;
}
return true;
}
times = '(years?|months?|weeks?|days?|hours?|minutes?|min|seconds?|sec' + '|sunday|sun\\.?|monday|mon\\.?|tuesday|tue\\.?|wednesday|wed\\.?' + '|thursday|thu\\.?|friday|fri\\.?|saturday|sat\\.?)';
regex = '([+-]?\\d+\\s' + times + '|' + '(last|next)\\s' + times + ')(\\sago)?';
match = text.match(new RegExp(regex, 'gi'));
if (!match) {
return fail;
}
for (i = 0, len = match.length; i < len; i++) {
if (!process(match[i])) {
return fail;
}
}
// ECMAScript 5 only
// if (!match.every(process))
// return false;
return date.getTime() / 1000;
}
var MAX_SAFE_INTEGER = 'MAX_SAFE_INTEGER' in Number ? Number.MAX_SAFE_INTEGER : 9007199254740991;
function random() {
var iterable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAX_SAFE_INTEGER;
if (_isNumber(iterable)) {
return _random(0, iterable);
}
return iterable[_random(0, iterable.length - 1)];
}
function min(iterable) {
for (var _len = arguments.length, additional = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
additional[_key - 1] = arguments[_key];
}
if (additional.length) {
return _min([iterable].concat(additional));
}
if (Array.isArray(iterable)) {
return _min(iterable);
}
return _min(_values(iterable));
}
function max(iterable) {
for (var _len2 = arguments.length, additional = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
additional[_key2 - 1] = arguments[_key2];
}
if (additional.length) {
return _max([iterable].concat(additional));
}
if (Array.isArray(iterable)) {
return _max(iterable);
}
return _max(_values(iterable));
}
function cycle(data, index) {
return data[index % data.length];
}
function attribute(obj, prop, args) {
if (Array.isArray(obj)) {
return obj[prop];
}
if (_isObject(obj)) {
if (obj.hasOwnProperty(prop)) {
return _isFunction(obj[prop]) ? obj[prop].apply(obj, args) : obj[prop];
}
var ucProp = _upperFirst(prop);
if (_isFunction(obj['get' + ucProp])) {
return obj['get' + ucProp]();
}
if (_isFunction(obj['is' + ucProp])) {
return obj['is' + ucProp]();
}
}
return undefined;
}
/**
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function inheritBlocks(template, usedTemplate, mappings) {
for (var name in usedTemplate) {
if (!usedTemplate.hasOwnProperty(name)) {
continue;
}
if (name !== 'render') {
if (mappings) {
var mappedName = mappings[name.substring(0, 7) + name[7].toLowerCase() + name.substring(8)];
if (mappedName) {
template[mappedName] = usedTemplate[name];
}
} else {
template[name] = usedTemplate[name];
}
}
}
}
function isEmpty(val) {
return val !== 0 && (!val || Array.isArray(val) && !val.length);
}
/**
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
exports.createSubContext = createSubContext;
exports.batch = batch;
exports.attrs = attrs;
exports.styles = styles;
exports.classes = classes;
exports.merge = merge;
exports.replace = replace;
exports.reverse = reverse;
exports.round = round;
exports.striptags = striptags;
exports.number_format = number_format;
exports.format = format;
exports.title = title;
exports.url_encode = url_encode;
exports.strtotime = strtotime;
exports.random = random;
exports.min = min;
exports.max = max;
exports.cycle = cycle;
exports.attribute = attribute;
exports.isEmpty = isEmpty;
exports.inheritBlocks = inheritBlocks;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var a=e(require("lodash/isString")),t=e(require("lodash/floor")),n=e(require("lodash/ceil")),o=e(require("lodash/round")),s=e(require("lodash/isObject")),i=e(require("lodash/isFunction")),u=e(require("lodash/upperFirst")),l=e(require("lodash/values")),c=e(require("lodash/max")),d=e(require("lodash/min")),r=e(require("lodash/random")),h=e(require("lodash/isNumber")),p=require("melody-idom");function f(e,r){var t=Object.create(e);return r&&Object.assign(t,r),t}function g(e,r){for(var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",n=[],o=e.length,a=0;a<o;a+=r){for(var s=[],i=0;i<r;i++)s[s.length]=a+i<o?e[a+i]:t;n[n.length]=s}return n}function m(e){var r=[];for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];r.push(t,!1===n||null===n||0===n||""===n?void 0:n)}return r}function y(e){for(var r="",t=Object.keys(e),n=0;n<t.length;n++){var o=e[t[n]];("string"==typeof o&&""!==o||"number"==typeof o&&!isNaN(o))&&(r+=t[n]+":"+o+";")}return r}function v(e){var r=[];for(var t in e)e.hasOwnProperty(t)&&("base"===t?r.push(e[t]):e[t]&&r.push(t));return r.join(" ")}function w(e,r){return Array.isArray(e)&&Array.isArray(r)?[].concat(e,r):Object.assign({},e,r)}function b(e,r){var t=e;for(var n in r)r.hasOwnProperty(n)&&(t=t.replace(n,r[n]));return t}function x(e){if(Array.isArray(e)){for(var r=[],t=e.length-1;0<=t;t--)r[r.length]=e[t];return r}if(a(e)){for(var n="",o=e.length-1;0<=o;o--)n+=e[o];return n}return e}function C(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;switch(2<arguments.length&&void 0!==arguments[2]?arguments[2]:"common"){case"ceil":return n(e,r);case"floor":return t(e,r);case"common":default:return o(e,r)}}function A(e){return e.replace(/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,"")}function D(e,r){var t=Math.pow(10,r);return""+(Math.round(e*t)/t).toFixed(r)}function E(e,r,t,n){var o,a=(e+"").replace(/[^0-9+\-Ee.]/g,""),s=isFinite(+a)?+a:0,i=isFinite(+r)?Math.abs(r):0,u=void 0===n?",":n,l=void 0===t?".":t;return 3<(o=(i?D(s,i):""+Math.round(s)).split("."))[0].length&&(o[0]=o[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,u)),(o[1]||"").length<i&&(o[1]=o[1]||"",o[1]+=new Array(i-o[1].length+1).join("0")),o.join(l)}function O(){for(var e=arguments.length,b=Array(e),r=0;r<e;r++)b[r]=arguments[r];var x=0,t=b[x++],C=function(e,r){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:" ",n=arguments[3],o=e.length>=r?"":new Array(1+r-e.length>>>0).join(t);return n?e+o:o+e},A=function(e,r,t,n,o,a){var s=n-e.length;return 0<s?t||!o?C(e,n,a,t):e.slice(0,r.length)+C("",s,"0",!0)+e.slice(r.length):e},D=function(e,r,t,n,o,a,s){var i=e>>>0,u=t&&i&&{2:"0b",8:"0",16:"0x"}[r]||"",l=u+C(i.toString(r),a||0,"0",!1);return A(l,u,n,o,s)},E=function(e,r,t,n,o,a){var s=e;return null!=n&&(s=s.slice(0,n)),A(s,"",r,t,o,a)};return t.replace(/%%|%(\d+\$)?([\-+\'#0 ]*)(\*\d+\$|\*|\d+)?(?:\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g,function(e,r,t,n,o,a){var s,i,u,l,c;if("%%"===e)return"%";var d,h=!1,p="",f=!1,g=!1,m=" ",y=t.length;for(d=0;t&&d<y;d++)switch(t.charAt(d)){case" ":p=" ";break;case"+":p="+";break;case"-":h=!0;break;case"'":m=t.charAt(d+1);break;case"0":f=!0,m="0";break;case"#":g=!0}var v=n;if((v=v?"*"===v?+b[x++]:"*"===v.charAt(0)?+b[v.slice(1,-1)]:+v:0)<0&&(v=-v,h=!0),!isFinite(v))throw new Error("sprintf: (minimum-)width must be finite");var w=o;switch(w=w?"*"===w?+b[x++]:"*"===w.charAt(0)?+b[w.slice(1,-1)]:+w:-1<"fFeE".indexOf(a)?6:"d"===a?0:void 0,c=r?b[r.slice(0,-1)]:b[x++],a){case"s":return E(String(c),h,v,w,f,m);case"c":return E(String.fromCharCode(+c),h,v,w,f);case"b":return D(c,2,g,h,v,w,f);case"o":return D(c,8,g,h,v,w,f);case"x":return D(c,16,g,h,v,w,f);case"X":return D(c,16,g,h,v,w,f).toUpperCase();case"u":return D(c,10,g,h,v,w,f);case"i":case"d":return s=+c||0,c=(i=(s=Math.round(s-s%1))<0?"-":p)+C(String(Math.abs(s)),w,"0",!1),A(c,i,h,v,f);case"e":case"E":case"f":case"F":case"g":case"G":return i=(s=+c)<0?"-":p,u=["toExponential","toFixed","toPrecision"]["efg".indexOf(a.toLowerCase())],l=["toString","toUpperCase"]["eEfFgG".indexOf(a)%2],c=i+Math.abs(s)[u](w),A(c,i,h,v,f)[l]();default:return e}})}function q(e){for(var r="",t=!0,n=0,o=e.length;n<o;n++){var a=e[n];"\n"===a||" "===a||"\t"===a?(t=!0,r+=a):t?(r+=a.toUpperCase(),t=!1):r+=a}return r}function F(e){if(a(e))return encodeURIComponent(e);var r=[];for(var t in e)e.hasOwnProperty(t)&&r.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return r.join("&")}function j(e,r){var t,n,o,a,c,d,h,s,i,u;if(!e)return!1;var l=e.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g," ").replace(/[\t\r\n]/g,"").toLowerCase();if((n=l.match(/^(\d{1,4})([\-\.\/\:])(\d{1,2})([\-\.\/\:])(\d{1,4})(?:\s(\d{1,2}):(\d{2})?:?(\d{2})?)?(?:\s([A-Z]+)?)?$/))&&n[2]===n[4])if(1901<n[1])switch(n[2]){case"-":return!(12<n[3]||31<n[5])&&new Date(n[1],parseInt(n[3],10)-1,n[5],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3;case".":return!1;case"/":return!(12<n[3]||31<n[5])&&new Date(n[1],parseInt(n[3],10)-1,n[5],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3}else if(1901<n[5])switch(n[2]){case"-":case".":return!(12<n[3]||31<n[1])&&new Date(n[5],parseInt(n[3],10)-1,n[1],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3;case"/":return!(12<n[1]||31<n[3])&&new Date(n[5],parseInt(n[1],10)-1,n[3],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3}else switch(n[2]){case"-":return!(12<n[3]||31<n[5]||n[1]<70&&38<n[1])&&(a=0<=n[1]&&n[1]<=38?+n[1]+2e3:n[1],new Date(a,parseInt(n[3],10)-1,n[5],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3);case".":return 70<=n[5]?!(12<n[3]||31<n[1])&&new Date(n[5],parseInt(n[3],10)-1,n[1],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3:n[5]<60&&!n[6]&&(!(23<n[1]||59<n[3])&&(o=new Date,new Date(o.getFullYear(),o.getMonth(),o.getDate(),n[1]||0,n[3]||0,n[5]||0,n[9]||0)/1e3));case"/":return!(12<n[1]||31<n[3]||n[5]<70&&38<n[5])&&(a=0<=n[5]&&n[5]<=38?+n[5]+2e3:n[5],new Date(a,parseInt(n[1],10)-1,n[3],n[6]||0,n[7]||0,n[8]||0,n[9]||0)/1e3);case":":return!(23<n[1]||59<n[3]||59<n[5])&&(o=new Date,new Date(o.getFullYear(),o.getMonth(),o.getDate(),n[1]||0,n[3]||0,n[5]||0)/1e3)}if("now"===l)return null===r||isNaN(r)?(new Date).getTime()/1e3|0:0|r;if(!isNaN(t=Date.parse(l)))return t/1e3|0;if((n=l.match(/^([0-9]{4}-[0-9]{2}-[0-9]{2})[ t]([0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?)([\+-][0-9]{2}(:[0-9]{2})?|z)/))&&("z"==n[4]?n[4]="Z":n[4].match(/^([\+-][0-9]{2})$/)&&(n[4]=n[4]+":00"),!isNaN(t=Date.parse(n[1]+"T"+n[2]+n[4]))))return t/1e3|0;function p(e){var r,t,n,o,a=e.split(" "),s=a[0],i=a[1].substring(0,3),u=/\d+/.test(s),l=("last"===s?-1:1)*("ago"===a[2]?-1:1);if(u&&(l*=parseInt(s,10)),h.hasOwnProperty(i)&&!a[1].match(/^mon(day|\.)?$/i))return c["set"+h[i]](c["get"+h[i]]()+l);if("wee"===i)return c.setDate(c.getDate()+7*l);if("next"===s||"last"===s)r=s,t=l,(n=void 0)!==(o=d[i])&&(0==(n=o-c.getDay())?n=7*t:0<n&&"last"===r?n-=7:n<0&&"next"===r&&(n+=7),c.setDate(c.getDate()+n));else if(!u)return!1;return!0}if(c=r?new Date(1e3*r):new Date,d={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},h={yea:"FullYear",mon:"Month",day:"Date",hou:"Hours",min:"Minutes",sec:"Seconds"},"([+-]?\\d+\\s"+(i="(years?|months?|weeks?|days?|hours?|minutes?|min|seconds?|sec|sunday|sun\\.?|monday|mon\\.?|tuesday|tue\\.?|wednesday|wed\\.?|thursday|thu\\.?|friday|fri\\.?|saturday|sat\\.?)")+"|(last|next)\\s"+i+")(\\sago)?",!(n=l.match(new RegExp("([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|minutes?|min|seconds?|sec|sunday|sun\\.?|monday|mon\\.?|tuesday|tue\\.?|wednesday|wed\\.?|thursday|thu\\.?|friday|fri\\.?|saturday|sat\\.?)|(last|next)\\s(years?|months?|weeks?|days?|hours?|minutes?|min|seconds?|sec|sunday|sun\\.?|monday|mon\\.?|tuesday|tue\\.?|wednesday|wed\\.?|thursday|thu\\.?|friday|fri\\.?|saturday|sat\\.?))(\\sago)?","gi"))))return!1;for(u=0,s=n.length;u<s;u++)if(!p(n[u]))return!1;return c.getTime()/1e3}function I(e,r){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"both";if(void 0===r&&"both"===t)return String(e).trim();if("both"!==t&&"left"!==t&&"right"!==t)throw new Error('Filter "trim". Invalid value '+t+' for parameter "side". Valid values are "both", "left", "right".');var n=e.length,o=0;if("both"===t||"left"===t)for(;o<n&&-1!==r.indexOf(e[o]);)o++;var a=n;if("both"===t||"right"===t)for(;0<a&&-1!==r.indexOf(e[a-1]);)a--;return e.substr(o,a-o)}var M="MAX_SAFE_INTEGER"in Number?Number.MAX_SAFE_INTEGER:9007199254740991;function k(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:M;return h(e)?r(0,e):e[r(0,e.length-1)]}function N(e){for(var r=arguments.length,t=Array(1<r?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return t.length?d([e].concat(t)):Array.isArray(e)?d(e):d(l(e))}function S(e){for(var r=arguments.length,t=Array(1<r?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return t.length?c([e].concat(t)):Array.isArray(e)?c(e):c(l(e))}function _(e,r){return e[r%e.length]}function P(e,r,t){if(Array.isArray(e))return e[r];if(s(e)){if(e.hasOwnProperty(r))return i(e[r])?e[r].apply(e,t):e[r];var n=u(r);if(i(e["get"+n]))return e["get"+n]();if(i(e["is"+n]))return e["is"+n]()}}function U(e,r,t){for(var n in r)if(r.hasOwnProperty(n)&&"render"!==n)if(t){var o=t[n.substring(0,7)+n[7].toLowerCase()+n.substring(8)];o&&(e[o]=r[n])}else e[n]=r[n]}function L(e){return 0!==e&&(!e||Array.isArray(e)&&!e.length)}var T=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},$=function(){function n(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),e}}(),R=function(){function e(){T(this,e),this.promisedComponent=null,this._el=null,this.refs=Object.create(null),this.props=null,this.resolvedComponent=null,this.alreadyUnmounted=!1,this.isLoading=!1,this.loadingError=null}return e.prototype.apply=function(e){var t=this,r=(this.props=e).promisedComponent;this.resolvedComponent&&this.resolvedComponent.apply(this.props.data),this.isLoading||(this.isLoading=!0,r().then(function(e){var r=e.default;t.alreadyUnmounted||(t.resolvedComponent=new r,p.link(t,t.resolvedComponent),t.resolvedComponent.el=t._el,t.resolvedComponent.apply(t.props.data))},function(e){t.loadingError=e,p.enqueueComponent(t)}).catch(function(e){t.loadingError=e,p.enqueueComponent(t)}),this.props.delayLoadingAnimation?setTimeout(function(){return p.enqueueComponent(t)},this.props.delayLoadingAnimation):p.enqueueComponent(this))},e.prototype.notify=function(){},e.prototype.componentWillUnmount=function(){this.alreadyUnmounted=!0},e.prototype.render=function(){this.resolvedComponent||(this.loadingError&&this.props.onError?this.props.onError(this.loadingError):this.props.whileLoading())},$(e,[{key:"el",set:function(e){return this.resolvedComponent&&(this.resolvedComponent.el=e),this._el=e},get:function(){return this.resolvedComponent?this.resolvedComponent.el:this._el}}]),e}();exports.AsyncComponent=R,exports.createSubContext=f,exports.batch=g,exports.attrs=m,exports.styles=y,exports.classes=v,exports.merge=w,exports.replace=b,exports.reverse=x,exports.round=C,exports.striptags=A,exports.number_format=E,exports.format=O,exports.title=q,exports.url_encode=F,exports.strtotime=j,exports.trim=I,exports.random=k,exports.min=N,exports.max=S,exports.cycle=_,exports.attribute=P,exports.isEmpty=L,exports.inheritBlocks=U;
{
"name": "melody-runtime",
"version": "1.2.0-commit.e725f50a",
"version": "1.2.0-f61c830.4+f61c830",
"description": "",

@@ -15,5 +15,6 @@ "main": "./lib/index.js",

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

@@ -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