How to use the es5-ext/array/#/last.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 / fs2 / descriptors-handler.js View on Github external
var release = function () {
	var data, fnCb;
	// eslint-disable-next-line no-unmodified-loop-condition
	while (count < limit && (data = queue.shift())) {
		try {
			data.fn.apply(data.context, data.args);
		} catch (e) {
			fnCb = last.call(data.args);
			if (typeof fnCb === "function") fnCb(e);
		}
	}
};
github medikoo / fs2 / watch.js View on Github external
(emitter._watchSwitchListener = function () {
			var candidate;
			watchers.alt.sort(compare);
			if (watchers.alt[0] !== watcher) return;

			if (isAvail()) {
				switchAltsToReg();
			} else if (watchers.reg.length) {
				candidate = last.call(watchers.reg.sort(compare));
				if (candidate.count >= watcher.count) return;

				// Move last regular watcher to lstat watch
				switchToAlt(candidate);

				// Move current watcher to regular watch
				switchToReg(watcher);
			}
		})
	);
github medikoo / esniff / test / _ast-function.js View on Github external
if (ast.callee.type !== 'MemberExpression') return false;
		object = ast.callee.object;
		if (object.type === 'MemberExpression') {
			if (!asProperty) return;
			if (object.property.name !== objName) return;
		} else if (object.name !== objName) {
			return;
		}
		if (ast.callee.property.name !== fnName) return;
		if (this.code[ast.range[0]] === '(') return;
		dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
		dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
		lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
		dep.line = ast.loc.start.line + lines.length - 1;
		dep.column = (lines.length > 1)
			? last.call(lines).length : ast.loc.start.column + lines[0].length;
		this.deps.push(dep);
	} else {
		if ((ast.type === 'CallExpression') && (ast.callee.type === 'Identifier') &&
				(ast.callee.name === fnName) && (this.code[ast.range[0]] !== '(')) {
			dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
			dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
			lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
			dep.line = ast.loc.start.line + lines.length - 1;
			dep.column = (lines.length > 1)
				? last.call(lines).length : ast.loc.start.column + lines[0].length;
			this.deps.push(dep);
		}
	}
};
github medikoo / find-requires / lib / ast.js View on Github external
if (!ast || (typeof ast !== 'object')) return;
	if (isArray(ast)) {
		ast.forEach(walker, this);
		return;
	}
	keys(ast).forEach(function (key) {
		if (key !== 'range') walker.call(this, ast[key]);
	}, this);
	if (((ast.type === 'CallExpression') || (ast.type === 'NewExpression')) &&
			(ast.callee.type === 'Identifier') &&
			(ast.callee.name === 'require') && (this.code[ast.range[0]] !== '(')) {
		dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
		dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
		lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
		dep.line = ast.loc.start.line + lines.length - 1;
		dep.column = (lines.length > 1) ? last.call(lines).length :
				ast.loc.start.column + lines[0].length;
		if ((ast.arguments.length === 1) && (ast.arguments[0].type === 'Literal')) {
			dep.value = String(ast.arguments[0].value);
		} else {
			if (ast.arguments.length === 1) {
				try {
					dep.value = String(parse(dep.raw));
				} catch (e) {
					try {
						dep.value = String(runInNewContext(dep.raw));
					} catch (ignore) {}
				}
			} else if (!ast.arguments.length) {
				dep.value = 'undefined';
			}
		}
github medikoo / modules-webmake / lib / parser.js View on Github external
return findRoot(input)(root => {
			let name, dirs, result;
			name = root ? last.call(root.split(sep)) : "/";
			if (!this.modules[name]) {
				this.packages[name] = root || sep;
				this.modules[name] = {};
			}
			scope = this.modules[name];
			dirs = root ? input.slice(root.length + 1) : input.slice(1);
			path = name + (root ? sep : "") + dirs;
			dirs = dirs.split(sep);
			name = dirs.pop();
			dirs.forEach(dir => {
				tree.push(scope);
				scope = scope[dir] || (scope[dir] = {});
			});
			if (scope[name]) return scope[name];
			if (!stream) {
				result = this.readFile(input, name, scope, tree);
github medikoo / irc-notifier / index.js View on Github external
if (
					keywords.some(function (keyword) {
						if (messageContains(keyword)) {
							needle = keyword;
							return true;
						}
					})
				) {
					console.log("Send email...");
					mailer.sendMail(
						{
							from: config.smtp.from,
							to: config.smtp.to,
							subject: (subject = "IRC: #" + name + ": '" + needle + "' mentioned"),
							text: (body =
								msgOutput(last.call(history)) +
								"\n\n----------\n\n" +
								history.map(msgOutput).join("\n") +
								"\n")
						},
						function (err) {
							if (err) {
								console.error("Could not send email: " + err);
								console.error(subject + ": " + body);
								throw new Error("Could not send emails");
							}
							console.log("...Email sent");
						}
					);
				}
			})
		);
github medikoo / fs2 / descriptors-handler.js View on Github external
fs.open = function (path, flags, mode, fnCb) {
		var openCount, args;
		if (count >= limit) {
			queue.push({ fn: fs.open, context: this, args: arguments });
			return;
		}
		openCount = count++;
		args = arguments;
		fnCb = last.call(args);
		++debugStats.fd;
		open(path, flags, mode, function (err, fd) {
			if (err) {
				--debugStats.fd;
				--count;
				if (err.code === "EMFILE" || err.code === "ENFILE") {
					if (limit > openCount) limit = openCount;
					queue.push({ fn: fs.open, context: this, args: args });
					release();
					return;
				}
				release();
			}
			if (typeof fnCb === "function") fnCb(err, fd);
		});
	};
github medikoo / fs2 / descriptors-handler.js View on Github external
return (self = defineLength(function () {
		var openCount, args = arguments, context, cb = last.call(args);
		if (!exports.initialized || typeof cb !== "function") return asyncFn.apply(this, arguments);
		if (count >= limit) {
			queue.push({ fn: self, context: this, args: arguments });
			return null;
		}
		openCount = count++;
		context = this;
		args = slice.call(args, 0, -1);
		args.push(function (err, resultIgnored) {
			--debugStats[type];
			--count;
			if (err && (err.code === "EMFILE" || err.code === "ENFILE")) {
				if (limit > openCount) limit = openCount;
				queue.push({ fn: self, context: context, args: args });
				release();
				return;
github medikoo / dbjs / lib / history.js View on Github external
forEach(history, function (events, id) {
		var event = events[0];
		if (!event || (event.value === undefined)) return;
		if ((property != null) && !event.obj.hasOwnProperty(property)) return;
		data[last.call(events).index] = events[0];
	});
	result = [];