How to use the es5-ext/string/#/ends-with.call function in es5-ext

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 / 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 / modules-webmake / lib / parser.js View on Github external
}').\n       Native node.js modules` +
								" are not ported to client-side. You can however provide" +
								" an alternative version of this module in your node_modules" +
								" path, it will be picked up by Webmake.\n"
						);
					}
					log.warn("Require of native %s approached (ignored)", name);
					return null;
				}
			}

			// Find package root
			if (!main) {
				// Try to calculate root by string subtraction
				ext = extname(path);
				if (endsWith.call(path, filename + ext)) {
					this.packages[name] = path.slice(
						0, name.length - (filename.length + ext.length)
					);
					return (this.modules[name] = {});
				}
				if (endsWith.call(path, filename)) {
					this.packages[name] = path.slice(0, name.length - filename.length);
					return (this.modules[name] = {});
				}
			}
			// Use dedicated findRoot
			const promise = (this.modules[name] = findRoot(path)(root => {
				const currentModule = {};
				this.packages[name] = root;
				return getMain(root)(mainModule => {
					currentModule[":mainpath:"] = mainModule;
github medikoo / dbjs / lib / objects.js View on Github external
createObject = function (id, proto) {
	var isProto, obj;

	if (isUpperCase(id[0])) {
		// Constructor or its prototype
		if (endsWith.call(id, '#')) {
			isProto = true;
			id = id.slice(0, -1);
			if (proto) proto = proto.ns;
		}

		if (!proto || (typeof proto !== 'function') ||
				(objects[proto._id_] !== proto)) {
			proto = objects.Base;
		}
		obj = proto.$$create(id);
		return isProto ? obj.prototype : obj;
	}

	// Instance
	if (!proto || (typeof proto === 'function') ||
			(objects[proto._id_] !== proto)) {
github medikoo / modules-webmake / lib / parser.js View on Github external
log.warn("Require of native %s approached (ignored)", name);
					return null;
				}
			}

			// Find package root
			if (!main) {
				// Try to calculate root by string subtraction
				ext = extname(path);
				if (endsWith.call(path, filename + ext)) {
					this.packages[name] = path.slice(
						0, name.length - (filename.length + ext.length)
					);
					return (this.modules[name] = {});
				}
				if (endsWith.call(path, filename)) {
					this.packages[name] = path.slice(0, name.length - filename.length);
					return (this.modules[name] = {});
				}
			}
			// Use dedicated findRoot
			const promise = (this.modules[name] = findRoot(path)(root => {
				const currentModule = {};
				this.packages[name] = root;
				return getMain(root)(mainModule => {
					currentModule[":mainpath:"] = mainModule;
					return currentModule;
				}, currentModule);
			}));
			promise.aside(currentModule => { this.modules[name] = currentModule; });
			return promise;
		})()(currentScope => {
github medikoo / controller-router / lib / get-router.js View on Github external
return defineProperty(function (path/*, …data*/) {
		var pathTokens, data = slice.call(arguments, 1), conf, controller, result, event;
		if (this) event = this;
		else if (eventProto) event = create(eventProto);
		else event = {};
		path = String(validValue(path));
		if (!path) return false;
		if (path[0] === '/') path = path.slice(1);
		if (endsWith.call(path, '/')) path = path.slice(0, -1);
		event.path = path || '/';
		conf = direct[path || '/'];
		if (conf) {
			controller = conf.controller || conf;
			try {
				result = apply.call(controller, event, data);
			} catch (e) {
				e.conf = conf;
				e.event = event;
				throw e;
			}
		} else {
			pathTokens = path.split('/');
			if (!match[pathTokens.length]) return false;
			match[pathTokens.length].some(function (data) {
				var args = [];
github medikoo / log / lib / setup-visibility.js View on Github external
ensureArray(debugNamespacesTokens).forEach(function (ns) {
		ns = ensureString(ns).trim();
		if (!ns) return;
		var isEnabled = ns[0] !== "-";
		if (!isEnabled) ns = ns.slice(1);
		if (endsWith.call(ns, ":*")) ns = ns.slice(0, -2);
		ns = ns.split(":").filter(Boolean).join(":");
		debugNamespacesSettings[ns] = isEnabled;
	});
};
github medikoo / fs2 / lib / get-conf-file-map.js View on Github external
paths = function (rootPath, path2) {
	var starter, data;
	starter = [rootPath];
	if (rootPath === path2) {
		return starter;
	}
	if (endsWith.call(rootPath, sep)) {
		data = path2.slice(rootPath.length).split(sep);
		starter.push((rootPath += data.shift()));
	} else {
		data = path2.slice(rootPath.length + 1).split(sep);
	}
	return starter.concat(data.map(function (path) { return (rootPath += sep + path); }));
};
github medikoo / dbjs / _setup / unserialize / key.js View on Github external
}
	}
	if (type === '4') {
		value = Number(value);
		if (isNaN(value)) throw new TypeError("Cannot unserialize: " + input);
		return new Date(value);
	}
	if (type === '5') {
		value = parse(value);
		flags = value.slice(value.lastIndexOf('/') + 1);
		return RegExp(value.slice(1, -(1 + flags.length)), flags);
	}
	if (type === '6') {
		data = parse(value).match(functionRe).slice(1);
		if (data[1][0] === '\n') data[1] = data[1].slice(1);
		if (endsWith.call(data[1], '\n')) data[1] = data[1].slice(0, -1);
		return Function.apply(null, data);
	}
	if (type === '7') {
		obj = objects.unserialize(value);
		if (obj._kind_ !== 'descriptor') return obj;
		return obj.object._getObject_(obj._sKey_);
	}
	throw new TypeError('Incorrect value');
};
github medikoo / dbjs / _setup / unserialize / value.js View on Github external
type = value[0];
	value = value.slice(1);
	if (type === '0') return null;
	if (type === '1') return Boolean(Number(value));
	if (type === '2') return Number(value);
	if (type === '3') return parse('"' + value + '"');
	if (type === '4') return new Date(Number(value));
	if (type === '5') {
		value = parse('"' + value + '"');
		flags = value.slice(value.lastIndexOf('/') + 1);
		return RegExp(value.slice(1, -(1 + flags.length)), flags);
	}
	if (type === '6') {
		data = parse('"' + value + '"').match(functionRe).slice(1);
		if (data[1][0] === '\n') data[1] = data[1].slice(1);
		if (endsWith.call(data[1], '\n')) data[1] = data[1].slice(0, -1);
		return Function.apply(null, data);
	}
	if (type === '7') {
		obj = objects.unserialize(value);
		if ((obj._kind_ === 'descriptor') && (obj.__id__ !== value)) {
			return obj.object._getObject_(obj._sKey_);
		}
		return obj;
	}
	throw new TypeError('Incorrect value');
};