How to use es5-ext - 10 common examples

To help you get started, we’ve selected a few es5-ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medikoo / duration / test / index.js View on Github external
"Hours": function (a) {
			// 4 hours 7 minutes 12 seconds 123 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 123);
			d2.setSeconds(d2.getSeconds() + 12);
			d2.setMinutes(d2.getMinutes() + 7);
			d2.setHours(d2.getHours() + 4);

			d = t(d1, d2);
			a(d.milliseconds, 4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 4 * 60 * 60 + 7 * 60 + 12, "Seconds");
			a(d.minutes, 4 * 60 + 7, "Minutes");
			a(d.hours, 4, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 123, "Trailing milliseconds");
github medikoo / duration / test / index.js View on Github external
"Seconds": function (a) {
			// 7 seconds 123 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 123);
			d2.setSeconds(d2.getSeconds() + 7);

			d = t(d1, d2);
			a(d.milliseconds, 7 * 1000 + 123, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 7, "Seconds");
			a(d.minutes, 0, "Minutes");
			a(d.hours, 0, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 123, "Trailing milliseconds");
			a(d.second, 7, "Trailing seconds");
			a(d.minute, 0, "Trailing minutes");
github medikoo / duration / test / index.js View on Github external
"Milliseconds": function (a) {
			// 11 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 11);

			d = t(d1, d2);
			a(d.milliseconds, 11, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 0, "Seconds");
			a(d.minutes, 0, "Minutes");
			a(d.hours, 0, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 11, "Trailing milliseconds");
			a(d.second, 0, "Trailing seconds");
			a(d.minute, 0, "Trailing minutes");
			a(d.hour, 0, "Trailing hours");
github medikoo / duration / test / index.js View on Github external
"Minutes": function (a) {
			// 7 minutes 12 seconds 123 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 123);
			d2.setSeconds(d2.getSeconds() + 12);
			d2.setMinutes(d2.getMinutes() + 7);

			d = t(d1, d2);
			a(d.milliseconds, 7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 7 * 60 + 12, "Seconds");
			a(d.minutes, 7, "Minutes");
			a(d.hours, 0, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 123, "Trailing milliseconds");
			a(d.second, 12, "Trailing seconds");
github medikoo / controller-router / index.js View on Github external
, asyncResult, callId = ++routeCallIdIndex;

		ensureObject(event);
		path = ensureStringifiable(path);

		this.emit("route:before", { event: event, path: path, args: controllerArgs });

		// Preprepare route data
		this.lastRouteData = { event: event };

		// Do not proceed for no path
		if (!path) return this._resolveResult(false);

		// Resolve path for route resolution
		if (path[0] === '/') path = path.slice(1);
		if (endsWith.call(path, '/')) path = path.slice(0, -1);
		event.path = path || '/';

		// Handle eventual static path
		conf = this._staticRoutes[path || '/'];
		if (conf) {
			initConf = this.routes[path || '/'];
			controller = conf.controller || conf;
			this.lastRouteData.conf =  initConf;
			return this._resolveController(apply.bind(controller, event, controllerArgs));
		}

		// Handle eventual dynamic paths
		pathTokens = path.split('/');
		if (!this._dynamicRoutes[pathTokens.length]) return this._resolveResult(false);
		this._dynamicRoutes[pathTokens.length].some(function (data) {
			var args = [], matchResult;
github medikoo / dbjs / lib / types-base / object.js View on Github external
this.__proto__ = proto;
	if (proto._id_) {
		proto = proto.ns;
		if (proto) {
			while (proto !== ObjectType) {
				proto[id] = this;
				proto = getPrototypeOf(proto);
				if (proto === Base) break;
			}
		}
	}

	// Fix relations proto
	getOwnPropertyNames(this).forEach(protoDeep.bind(this, nu));

	if (old._id_) remove.call(old._children_, this);
	if (nu._id_) {
		if (!nu.hasOwnProperty('_children_')) {
			defineProperty(nu, '_children_', d('', []));
		}
		nu._children_.push(this);
	}
	if (old._id_) old.emit('delete', this);
	if (nu._id_) nu.emit('add', this);
}));
github medikoo / dbjs / lib / types-base / base.js View on Github external
if (!nu.prototype) {
		// Should never happen, but we better take it easy
		// It's result of corrupted database (via e.g. malformed/not-proper import
		// messages) or trial of fixing the corrupted database
		Plain.prototype.$$proto.call(this, nu);
		return;
	}
	this.__proto__ = nu;
	this.prototype.__proto__ = nu.prototype;

	// Fix relations proto
	getOwnPropertyNames(this).forEach(protoDeep.bind(this, nu));
	getOwnPropertyNames(this.prototype)
		.forEach(protoDeep.bind(this, nu.prototype));

	if (old !== Plain) remove.call(old._children_, this);
	if (nu !== Plain) {
		if (!nu.hasOwnProperty('_children_')) {
			defineProperty(nu, '_children_', d('', []));
		}
		nu._children_.push(this);
	}
	if (old !== Plain) old.emit('delete', this, this._id_);
	if (nu !== Plain) nu.emit('add', this, this._id_);
}));
github medikoo / dbjs / lib / types-base / base.js View on Github external
_forEachObject_: d('c', function (cb) {
		getOwnPropertyNames(this).forEach(function (name) {
			var value;
			if (!startsWith.call(name, '__')) return;
			if (name === '__value') return;
			value = this[name];
			if (!value._id_) return;
			if (!value.hasOwnProperty('_value')) return;
			cb(value, value._id_, this);
		}, this);
	}),
	rel: d('c', function (data) {
		if (data == null) return this;
		return new RelTransport(this, data);
	}),
	required: d.gs('c', function () {
		return new RelTransport(this, { required: true });
	}),

	coerce: d('c', function (value) { return value; }),
	_serialize_: d('c', serialize)
});

defineProperty(Plain, '$$proto', d('c', function (nu) {
	var old = getPrototypeOf(this);
	if (!nu) {
		nu = Plain;
		delete Base[this._id_];
	}
	if (old === nu) return;
	if (!nu.prototype) {
		// Should never happen, but we better take it easy
github medikoo / dbjs / lib / types / base.js View on Github external
$$setValue: d('c', function (nu) {
		var old = getPrototypeOf(this), objects;
		if (!nu) nu = Base;
		if (old === nu) return;

		if (old._childType_ === 'object') objects = this.values;

		this.__proto__ = nu;
		this.prototype.__proto__ = nu.prototype;

		remove.call(old._children_, this);
		remove.call(old.prototype._children_, this.prototype);

		if (!nu.hasOwnProperty('_children_')) {
			defineProperty(nu, '_children_', d('', []));
		}
		if (!nu.prototype.hasOwnProperty('_children_')) {
			defineProperty(nu.prototype, '_children_', d('', []));
		}
		nu._children_.push(this);
		nu.prototype._children_.push(this);

		if (old === Base) Base[this._id_] = this;
		if (nu === Base) delete Base[this._id_];

		// Fix relations proto
		this._forEachRelation_(setRelationProto.bind(nu));
		this.prototype._forEachRelation_(setRelationProto.bind(nu.prototype));
github medikoo / dbjs / lib / types / base.js View on Github external
$$setValue: d('c', function (nu) {
		var old = getPrototypeOf(this), objects;
		if (!nu) nu = Base;
		if (old === nu) return;

		if (old._childType_ === 'object') objects = this.values;

		this.__proto__ = nu;
		this.prototype.__proto__ = nu.prototype;

		remove.call(old._children_, this);
		remove.call(old.prototype._children_, this.prototype);

		if (!nu.hasOwnProperty('_children_')) {
			defineProperty(nu, '_children_', d('', []));
		}
		if (!nu.prototype.hasOwnProperty('_children_')) {
			defineProperty(nu.prototype, '_children_', d('', []));
		}
		nu._children_.push(this);
		nu.prototype._children_.push(this);

		if (old === Base) Base[this._id_] = this;
		if (nu === Base) delete Base[this._id_];

		// Fix relations proto
		this._forEachRelation_(setRelationProto.bind(nu));