1 | /* Javascript Object Inheritance Implementation ______ ________ |
||
2 | * (c) 2016 <[email protected]> __ / / __ \/ _/ _/ |
||
3 | * Licensed under MIT. / // / /_/ // /_/ / |
||
4 | * ------------------------------------------------------ \___/\____/___/__*/ |
||
5 | |||
6 | // Need this to be in scope for internal functions, but don't want to expose it outside |
||
7 | // this will be inside the closure after compile, while still being available in global scope for src testing |
||
8 | var inner_static_objects = {}; |
||
9 | |||
10 | |||
11 | |||
12 | JOII = typeof (JOII) !== 'undefined' ? JOII : {}; |
||
13 | JOII.Config = { |
||
14 | constructors : ['__construct', 'construct', '->', '=>'], |
||
15 | callables : ['__call', '<>'], |
||
16 | |||
17 | |||
18 | /** |
||
19 | * Adds a constructor method name. The first occurance of a function |
||
20 | * named like one of these is executed. The rest is ignored to prevent |
||
21 | * ambiguous behavior. |
||
22 | * |
||
23 | * @param {string} name |
||
24 | */ |
||
25 | addConstructor : function (name) { |
||
26 | if (JOII.Config.constructors.indexOf(name) !== -1) { |
||
0 ignored issues
–
show
|
|||
27 | return; |
||
28 | } |
||
29 | |||
30 | JOII.Config.constructors.push(name); |
||
31 | }, |
||
32 | |||
33 | /** |
||
34 | * Removes a constructor method name. The first occurance of a function |
||
35 | * named like one of these is executed. The rest is ignored to prevent |
||
36 | * ambiguous behavior. |
||
37 | * |
||
38 | * @param {string} name |
||
39 | */ |
||
40 | removeConstructor: function(name) { |
||
41 | if (JOII.Config.constructors.indexOf(name) === -1) { |
||
0 ignored issues
–
show
This function should enable strict mode with
use strict .
Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors. Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations. We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website. ![]() |
|||
42 | return; |
||
43 | } |
||
44 | |||
45 | JOII.Config.constructors.splice(JOII.Config.constructors.indexOf(name), 1); |
||
46 | }, |
||
47 | |||
48 | /** |
||
49 | * Adds a callable method name, like __call. Only one of these is |
||
50 | * executed if more than one exist to prevent ambiguous behaviour. |
||
51 | * |
||
52 | * @param {string} name |
||
53 | */ |
||
54 | addCallable: function (name) { |
||
55 | if (JOII.Config.callables.indexOf(name) !== -1) { |
||
0 ignored issues
–
show
This function should enable strict mode with
use strict .
Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors. Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations. We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website. ![]() |
|||
56 | return; |
||
57 | } |
||
58 | |||
59 | JOII.Config.callables.push(name); |
||
60 | }, |
||
61 | |||
62 | /** |
||
63 | * Removes a callable method name, like __call. Only one of these is |
||
64 | * executed if more than one exist to prevent ambiguous behaviour. |
||
65 | * |
||
66 | * @param {string} name |
||
67 | */ |
||
68 | removeCallable: function(name) { |
||
69 | if (JOII.Config.callables.indexOf(name) === -1) { |
||
0 ignored issues
–
show
This function should enable strict mode with
use strict .
Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors. Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations. We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website. ![]() |
|||
70 | return; |
||
71 | } |
||
72 | |||
73 | JOII.Config.callables.splice(JOII.Config.callables.indexOf(name), 1); |
||
74 | } |
||
75 | }; |
||
76 |
Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors.
Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations.
We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website.