PageSourceSearch

https://account.internationalairportreview.com/Javascript/mootools/core/Types/FunctionSimplified.js

js internationalairportreview.com collected 2026-10-02 03:43:14 UTC 2,894 bytes, 128 lines download raw bytes

1/*
2---
3
4name: Function
5
6description: Contains Function Prototypes like create, bind, pass, and delay.
7
8license: MIT-style license.
9
10requires: Type
11
12provides: Function
13
14...
15*/
16
17Function.extend({
18
19	attempt: function(){
20		for (var i = 0, l = arguments.length; i < l; i++){
21			try {
22				return arguments[i]();
23			} catch (e){}
24		}
25		return null;
26	}
27
28});
29
30Function.implement({
31
32	attempt: function(args, bind){
33		try {
34			return this.apply(bind, Array.from(args));
35		} catch (e){}
36
37		return null;
38	},
39
40	/*<!ES5-bind>*/
41	bind: function(that){
42		var self = this,
43			args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
44			F = function(){};
45
46		var bound = function(){
47			var context = that, length = arguments.length;
48			if (this instanceof bound){
49				F.prototype = self.prototype;
50				context = new F;
51			}
52			var result = (!args && !length)
53				? self.call(context)
54				: self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
55			return context == that ? result : context;
56		};
57		return bound;
58	},
59	/*</!ES5-bind>*/
60
61	pass: function(args, bind){
62		var self = this;
63		if (args != null) args = Array.from(args);
64		return function(){
65			return self.apply(bind, args || arguments);
66		};
67	},
68
69	delay: function(delay, bind, args){
70		return setTimeout(this.pass((args == null ? [] : args), bind), delay);
71	},
72
73	periodical: function(periodical, bind, args){
74		return setInterval(this.pass((args == null ? [] : args), bind), periodical);
75	}
76
77});
78
79//<1.2compat>
80
81//delete Function.prototype.bind;
82
83Function.implement({
84
85	create: function(options){
86		var self = this;
87		options = options || {};
88		return function(event){
89			var args = options.arguments;
90			args = (args != null) ? Array.from(args) : Array.slice(arguments, (options.event) ? 1 : 0);
91			if (options.event) args = [event || window.event].extend(args);
92			var returns = function(){
93				return self.apply(options.bind || null, args);
94			};
95			if (options.delay) return setTimeout(returns, options.delay);
96			if (options.periodical) return setInterval(returns, options.periodical);
97			if (options.attempt) return Function.attempt(returns);
98			return returns();
99		};
100	},
101
102	//bind: function(bind, args){
103	//	var self = this;
104	//	if (args != null) args = Array.from(args);
105	//	return function(){
106	//		return self.apply(bind, args || arguments);
107	//	};
108	//},
109
110	bindWithEvent: function(bind, args){
111		var self = this;
112		if (args != null) args = Array.from(args);
113		return function(event){
114			return self.apply(bind, (args == null) ? arguments : [event].concat(args));
115		};
116	},
117
118	run: function(args, bind){
119		return this.apply(bind, Array.from(args));
120	}
121
122});
123
124if (Object.create == Function.prototype.create) Object.create = null;
125
126var $try = Function.attempt;
127
128//</1.2compat>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.