Skip to content

Commit ae6d5af

Browse files
committed
Fix whitespace issues in experimental
1 parent fbf8f59 commit ae6d5af

File tree

143 files changed

+320839
-320833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+320839
-320833
lines changed

experimental/array/extract.js

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function extract (arr, type, prefix) {
99
// * example 1: color+'-'+size+'-'+shape+'-'+wddx_size;
1010
// * returns 1: 'blue-large-sphere-medium'
1111
if (Object.prototype.toString.call(arr) === '[object Array]' &&
12-
(type !== 'EXTR_PREFIX_ALL' && type !== 'EXTR_PREFIX_INVALID')) {
12+
(type !== 'EXTR_PREFIX_ALL' && type !== 'EXTR_PREFIX_INVALID')) {
1313
return 0;
1414
}
1515
var targetObj = this.window;
@@ -23,60 +23,60 @@ function extract (arr, type, prefix) {
2323
var prefixed = prefix + '_' + i;
2424
try {
2525
switch (type) {
26-
case 'EXTR_PREFIX_SAME' || 2:
27-
if (targetObj[i] !== undefined) {
26+
case 'EXTR_PREFIX_SAME' || 2:
27+
if (targetObj[i] !== undefined) {
28+
if (prefixed.match(validIdent) !== null) {
29+
targetObj[prefixed] = arr[i];
30+
++chng;
31+
}
32+
} else {
33+
targetObj[i] = arr[i];
34+
++chng;
35+
}
36+
break;
37+
case 'EXTR_SKIP' || 1:
38+
if (targetObj[i] === undefined) {
39+
targetObj[i] = arr[i];
40+
++chng;
41+
}
42+
break;
43+
case 'EXTR_PREFIX_ALL' || 3:
2844
if (prefixed.match(validIdent) !== null) {
2945
targetObj[prefixed] = arr[i];
3046
++chng;
3147
}
32-
} else {
33-
targetObj[i] = arr[i];
34-
++chng;
35-
}
36-
break;
37-
case 'EXTR_SKIP' || 1:
38-
if (targetObj[i] === undefined) {
39-
targetObj[i] = arr[i];
40-
++chng;
41-
}
42-
break;
43-
case 'EXTR_PREFIX_ALL' || 3:
44-
if (prefixed.match(validIdent) !== null) {
45-
targetObj[prefixed] = arr[i];
46-
++chng;
47-
}
48-
break;
49-
case 'EXTR_PREFIX_INVALID' || 4:
50-
if (i.match(validIdent) !== null) {
51-
if (prefixed.match(validIdent) !== null) {
48+
break;
49+
case 'EXTR_PREFIX_INVALID' || 4:
50+
if (i.match(validIdent) !== null) {
51+
if (prefixed.match(validIdent) !== null) {
52+
targetObj[prefixed] = arr[i];
53+
++chng;
54+
}
55+
} else {
56+
targetObj[i] = arr[i];
57+
++chng;
58+
}
59+
break;
60+
case 'EXTR_IF_EXISTS' || 6:
61+
if (targetObj[i] !== undefined) {
62+
targetObj[i] = arr[i];
63+
++chng;
64+
}
65+
break;
66+
case 'EXTR_PREFIX_IF_EXISTS' || 5:
67+
if (targetObj[i] !== undefined && prefixed.match(validIdent) !== null) {
5268
targetObj[prefixed] = arr[i];
5369
++chng;
5470
}
55-
} else {
56-
targetObj[i] = arr[i];
57-
++chng;
58-
}
59-
break;
60-
case 'EXTR_IF_EXISTS' || 6:
61-
if (targetObj[i] !== undefined) {
71+
break;
72+
case 'EXTR_REFS' || 256:
73+
throw 'The EXTR_REFS type will not work in JavaScript';
74+
case 'EXTR_OVERWRITE' || 0:
75+
// Fall-through
76+
default:
6277
targetObj[i] = arr[i];
6378
++chng;
64-
}
65-
break;
66-
case 'EXTR_PREFIX_IF_EXISTS' || 5:
67-
if (targetObj[i] !== undefined && prefixed.match(validIdent) !== null) {
68-
targetObj[prefixed] = arr[i];
69-
++chng;
70-
}
71-
break;
72-
case 'EXTR_REFS' || 256:
73-
throw 'The EXTR_REFS type will not work in JavaScript';
74-
case 'EXTR_OVERWRITE' || 0:
75-
// Fall-through
76-
default:
77-
targetObj[i] = arr[i];
78-
++chng;
79-
break;
79+
break;
8080
}
8181
} catch (e) { // Just won't increment for problem assignments
8282
}

experimental/array/list.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
function list () {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Brett Zamir (http://brett-zamir.me)
4-
// % note 1: Only works in global context and deviates (by necessity) from
5-
// % note 1: PHP version by adding the array (which in PHP is an rvalue
6-
// % note 1: separate from the list() lvalue) as the last argument
7-
// * example 1: var drink, color, power;
8-
// * example 1: list('drink', 'color', 'power', ['coffee', 'brown', 'caffeine']);
9-
// * example 1: drink +' is '+color+' and '+power+' makes it special.\n';
10-
// * returns 1: 'coffee is brown and caffeine makes it special.\n'
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Brett Zamir (http://brett-zamir.me)
4+
// % note 1: Only works in global context and deviates (by necessity) from
5+
// % note 1: PHP version by adding the array (which in PHP is an rvalue
6+
// % note 1: separate from the list() lvalue) as the last argument
7+
// * example 1: var drink, color, power;
8+
// * example 1: list('drink', 'color', 'power', ['coffee', 'brown', 'caffeine']);
9+
// * example 1: drink +' is '+color+' and '+power+' makes it special.\n';
10+
// * returns 1: 'coffee is brown and caffeine makes it special.\n'
1111

12-
var i = 0, arr = [];
12+
var i = 0, arr = [];
1313

14-
arr = arguments[arguments.length-1];
14+
arr = arguments[arguments.length - 1];
1515

16-
if (arr && typeof arr === 'object' && arr.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
17-
return arr.list.apply(arr, Array.prototype.slice.call(arguments, 0, -1));
16+
if (arr && typeof arr === 'object' && arr.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
17+
return arr.list.apply(arr, Array.prototype.slice.call(arguments, 0, -1));
18+
}
19+
if (arr && typeof arr === 'object' && arr.length && !arr.propertyIsEnumerable('length')) {
20+
for (i = 0; i < arr.length; i++) {
21+
this.window[arguments[i]] = arr[i];
1822
}
19-
if (arr && typeof arr === 'object' && arr.length && !arr.propertyIsEnumerable('length')) {
20-
for (i = 0; i < arr.length; i++) {
21-
this.window[arguments[i]] = arr[i];
22-
}
23-
}
24-
else {
25-
for (i in arr) {
26-
if (i.length === parseInt(i).toString().length && parseInt(i) < arguments.length-1) {
27-
this.window[arguments[i]] = arr[i];
28-
}
29-
}
23+
}
24+
else {
25+
for (i in arr) {
26+
if (i.length === parseInt(i).toString().length && parseInt(i) < arguments.length - 1) {
27+
this.window[arguments[i]] = arr[i];
28+
}
3029
}
30+
}
3131

32-
return arr;
32+
return arr;
3333
}

experimental/classkit/classkit_method_add.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ function classkit_method_add (classname, methodname, args, code, flags) {
88
var func, argmnts = [];
99

1010
switch (flags) {
11-
case 'CLASSKIT_ACC_PROTECTED':
12-
throw 'Protected not supported';
13-
case 'CLASSKIT_ACC_PRIVATE':
14-
throw 'Private not supported';
15-
case 'CLASSKIT_ACC_PUBLIC':
16-
default:
17-
break;
11+
case 'CLASSKIT_ACC_PROTECTED':
12+
throw 'Protected not supported';
13+
case 'CLASSKIT_ACC_PRIVATE':
14+
throw 'Private not supported';
15+
case 'CLASSKIT_ACC_PUBLIC':
16+
default:
17+
break;
1818
}
1919

2020
argmnts = args.split(/,\s*/);

experimental/classkit/classkit_method_copy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function classkit_method_copy (dClass, dMethod, sClass, sMethod) {
44
// * example 1: classkit_method_copy('newClass', 'newMethod', 'someClass', 'someMethod');
55
// * returns 1: true
66

7-
/*
7+
/*
88
function A(){}
99
function C(){}
1010
C.d = function () {alert('inside d');}

experimental/classkit/classkit_method_redefine.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ function classkit_method_redefine (classname, methodname, args, code, flags) {
77
// In JavaScript, this is identical to classkit_method_add
88

99
var argmnts = [],
10-
func;
10+
func;
1111

1212
switch (flags) {
13-
case 'CLASSKIT_ACC_PROTECTED':
14-
throw 'Protected not supported';
15-
case 'CLASSKIT_ACC_PRIVATE':
16-
throw 'Private not supported';
17-
case 'CLASSKIT_ACC_PUBLIC':
18-
default:
19-
break;
13+
case 'CLASSKIT_ACC_PROTECTED':
14+
throw 'Protected not supported';
15+
case 'CLASSKIT_ACC_PRIVATE':
16+
throw 'Private not supported';
17+
case 'CLASSKIT_ACC_PUBLIC':
18+
default:
19+
break;
2020
}
2121

2222
argmnts = args.split(/,\s*/);

experimental/classkit/classkit_method_rename.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function classkit_method_rename (classname, methodname, newname) {
88
classname = this.window[classname];
99
}
1010

11-
/*
11+
/*
1212
var method = classname[methodname]; // Static
1313
classname[newname] = method;
1414
delete classname[methodname];
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
function call_user_method(method, obj) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Brett Zamir (http://brett-zamir.me)
4-
// + input by: dnukem
5-
// + improved by: Brett Zamir (http://brett-zamir.me)
6-
// - depends on: Exception
7-
// % note 1: Deprecated in PHP
8-
// * example 1: call_user_method('alert', this.window, 'Hello!');
9-
// * returns 1: 'Hello!'
10-
// * example 2: call_user_method([this.window, 'alert'], 'Hello!');
11-
// * returns 2: 'Hello!'
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Brett Zamir (http://brett-zamir.me)
4+
// + input by: dnukem
5+
// + improved by: Brett Zamir (http://brett-zamir.me)
6+
// - depends on: Exception
7+
// % note 1: Deprecated in PHP
8+
// * example 1: call_user_method('alert', this.window, 'Hello!');
9+
// * returns 1: 'Hello!'
10+
// * example 2: call_user_method([this.window, 'alert'], 'Hello!');
11+
// * returns 2: 'Hello!'
1212

13-
var func, object = obj, methodName = method, paramBegin = 2;
14-
if (method && typeof method === 'object' && method.length) {
15-
paramBegin = 1;
16-
object = method[0];
17-
object = typeof object === 'string' ? this.window[object] : object;
18-
methodName = method[1];
19-
}
20-
func = object[methodName];
13+
var func, object = obj, methodName = method, paramBegin = 2;
14+
if (method && typeof method === 'object' && method.length) {
15+
paramBegin = 1;
16+
object = method[0];
17+
object = typeof object === 'string' ? this.window[object] : object;
18+
methodName = method[1];
19+
}
20+
func = object[methodName];
2121

22-
if (typeof func !== 'function') {
23-
throw new this.Exception(func + ' is not a valid method');
24-
}
22+
if (typeof func !== 'function') {
23+
throw new this.Exception(func + ' is not a valid method');
24+
}
2525

26-
return func.apply(object, Array.prototype.slice.call(arguments, paramBegin));
26+
return func.apply(object, Array.prototype.slice.call(arguments, paramBegin));
2727
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
function call_user_method_array(method, obj, params) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Brett Zamir (http://brett-zamir.me)
4-
// + input by: dnukem
5-
// + improved by: Brett Zamir (http://brett-zamir.me)
6-
// - depends on: Exception
7-
// % note 1: Deprecated in PHP
8-
// * example 1: call_user_method_array('alert', this.window, ['Hello!']);
9-
// * returns 1: 'Hello!'
10-
// * example 1: call_user_method_array([this.window, 'alert'], ['Hello!']);
11-
// * returns 1: 'Hello!'
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Brett Zamir (http://brett-zamir.me)
4+
// + input by: dnukem
5+
// + improved by: Brett Zamir (http://brett-zamir.me)
6+
// - depends on: Exception
7+
// % note 1: Deprecated in PHP
8+
// * example 1: call_user_method_array('alert', this.window, ['Hello!']);
9+
// * returns 1: 'Hello!'
10+
// * example 1: call_user_method_array([this.window, 'alert'], ['Hello!']);
11+
// * returns 1: 'Hello!'
1212

13-
var func, object = obj, methodName = method;
14-
if (method && typeof method === 'object' && method.length) {
15-
params = obj;
16-
object = method[0];
17-
object = typeof object === 'string' ? this.window[object] : object;
18-
methodName = method[1];
19-
}
20-
func = object[methodName];
13+
var func, object = obj, methodName = method;
14+
if (method && typeof method === 'object' && method.length) {
15+
params = obj;
16+
object = method[0];
17+
object = typeof object === 'string' ? this.window[object] : object;
18+
methodName = method[1];
19+
}
20+
func = object[methodName];
2121

22-
if (typeof func !== 'function') {
23-
throw new this.Exception(func + ' is not a valid method');
24-
}
22+
if (typeof func !== 'function') {
23+
throw new this.Exception(func + ' is not a valid method');
24+
}
2525

26-
return func.apply(object, params);
26+
return func.apply(object, params);
2727
}

experimental/classobj/get_class_methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function get_class_methods (name) {
88
// * example 1: get_class_methods('MyClass')
99
// * returns 1: {}
1010
var constructor, retArr = {},
11-
method = '';
11+
method = '';
1212

1313
if (typeof name === 'function') {
1414
constructor = name;

experimental/classobj/get_class_vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function get_class_vars (name) {
99
// * returns 1: {}
1010

1111
var constructor, retArr = {},
12-
prop = '';
12+
prop = '';
1313

1414
if (typeof name === 'function') {
1515
constructor = name;

experimental/classobj/get_declared_classes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function get_declared_classes () {
1111
// * returns 1: [C, B, A]
1212

1313
var i = '',
14-
j = '',
15-
arr = [],
16-
already = {};
14+
j = '',
15+
arr = [],
16+
already = {};
1717

1818
for (i in this.window) {
1919
try {

experimental/classobj/get_object_vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function get_object_vars (obj) {
88
// * example 1: get_object_vars('MyClass')
99
// * returns 1: {}
1010
var retArr = {},
11-
prop = '';
11+
prop = '';
1212

1313
for (prop in obj) {
1414
if (typeof obj[prop] !== 'function' && prop !== 'prototype') {

experimental/datetime/date_add.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function date_add (dt, interval) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Brett Zamir (http://brett-zamir.me)
4-
// * example 1: var dt = date_create();
5-
// * example 1: var dti = date_interval_create_from_date_string('+1 day');
6-
// * example 1: date_add(dt, dti);
7-
// * returns 1: {}
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Brett Zamir (http://brett-zamir.me)
4+
// * example 1: var dt = date_create();
5+
// * example 1: var dti = date_interval_create_from_date_string('+1 day');
6+
// * example 1: date_add(dt, dti);
7+
// * returns 1: {}
88

9-
// Fix: need to check argument to the dti example above
9+
// Fix: need to check argument to the dti example above
1010

11-
return dt.add(interval);
11+
return dt.add(interval);
1212
}

0 commit comments

Comments
 (0)