Skip to content

Commit e666d23

Browse files
committed
Switched codebase to 2 spaces
1 parent 1beb684 commit e666d23

451 files changed

Lines changed: 21086 additions & 21086 deletions

File tree

Some content is hidden

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

functions/_phpjs_shared/_phpjs_shared_bc.js

Lines changed: 1133 additions & 1133 deletions
Large diffs are not rendered by default.

functions/array/array.js

Lines changed: 273 additions & 273 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
function array_change_key_case (array, cs) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Ates Goral (http://magnetiq.com)
4-
// + improved by: marrtins
5-
// + improved by: Brett Zamir (http://brett-zamir.me)
6-
// * example 1: array_change_key_case(42);
7-
// * returns 1: false
8-
// * example 2: array_change_key_case([ 3, 5 ]);
9-
// * returns 2: {0: 3, 1: 5}
10-
// * example 3: array_change_key_case({ FuBaR: 42 });
11-
// * returns 3: {"fubar": 42}
12-
// * example 4: array_change_key_case({ FuBaR: 42 }, 'CASE_LOWER');
13-
// * returns 4: {"fubar": 42}
14-
// * example 5: array_change_key_case({ FuBaR: 42 }, 'CASE_UPPER');
15-
// * returns 5: {"FUBAR": 42}
16-
// * example 6: array_change_key_case({ FuBaR: 42 }, 2);
17-
// * returns 6: {"FUBAR": 42}
18-
var case_fn, key, tmp_ar = {};
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Ates Goral (http://magnetiq.com)
4+
// + improved by: marrtins
5+
// + improved by: Brett Zamir (http://brett-zamir.me)
6+
// * example 1: array_change_key_case(42);
7+
// * returns 1: false
8+
// * example 2: array_change_key_case([ 3, 5 ]);
9+
// * returns 2: {0: 3, 1: 5}
10+
// * example 3: array_change_key_case({ FuBaR: 42 });
11+
// * returns 3: {"fubar": 42}
12+
// * example 4: array_change_key_case({ FuBaR: 42 }, 'CASE_LOWER');
13+
// * returns 4: {"fubar": 42}
14+
// * example 5: array_change_key_case({ FuBaR: 42 }, 'CASE_UPPER');
15+
// * returns 5: {"FUBAR": 42}
16+
// * example 6: array_change_key_case({ FuBaR: 42 }, 2);
17+
// * returns 6: {"FUBAR": 42}
18+
var case_fn, key, tmp_ar = {};
1919

20-
if (Object.prototype.toString.call(array) === '[object Array]') {
21-
return array;
20+
if (Object.prototype.toString.call(array) === '[object Array]') {
21+
return array;
22+
}
23+
if (array && typeof array === 'object' && array.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
24+
return array.change_key_case(cs);
25+
}
26+
if (array && typeof array === 'object' ) {
27+
case_fn = (!cs || cs === 'CASE_LOWER') ? 'toLowerCase' : 'toUpperCase';
28+
for (key in array) {
29+
tmp_ar[key[case_fn]()] = array[key];
2230
}
23-
if (array && typeof array === 'object' && array.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
24-
return array.change_key_case(cs);
25-
}
26-
if (array && typeof array === 'object' ) {
27-
case_fn = (!cs || cs === 'CASE_LOWER') ? 'toLowerCase' : 'toUpperCase';
28-
for (key in array) {
29-
tmp_ar[key[case_fn]()] = array[key];
30-
}
31-
return tmp_ar;
32-
}
33-
return false;
31+
return tmp_ar;
32+
}
33+
return false;
3434
}

functions/array/array_chunk.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
function array_chunk (input, size, preserve_keys) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
4-
// + improved by: Brett Zamir (http://brett-zamir.me)
5-
// % note 1: Important note: Per the ECMAScript specification, objects may not always iterate in a predictable order
6-
// * example 1: array_chunk(['Kevin', 'van', 'Zonneveld'], 2);
7-
// * returns 1: [['Kevin', 'van'], ['Zonneveld']]
8-
// * example 2: array_chunk(['Kevin', 'van', 'Zonneveld'], 2, true);
9-
// * returns 2: [{0:'Kevin', 1:'van'}, {2: 'Zonneveld'}]
10-
// * example 3: array_chunk({1:'Kevin', 2:'van', 3:'Zonneveld'}, 2);
11-
// * returns 3: [['Kevin', 'van'], ['Zonneveld']]
12-
// * example 4: array_chunk({1:'Kevin', 2:'van', 3:'Zonneveld'}, 2, true);
13-
// * returns 4: [{1: 'Kevin', 2: 'van'}, {3: 'Zonneveld'}]
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
4+
// + improved by: Brett Zamir (http://brett-zamir.me)
5+
// % note 1: Important note: Per the ECMAScript specification, objects may not always iterate in a predictable order
6+
// * example 1: array_chunk(['Kevin', 'van', 'Zonneveld'], 2);
7+
// * returns 1: [['Kevin', 'van'], ['Zonneveld']]
8+
// * example 2: array_chunk(['Kevin', 'van', 'Zonneveld'], 2, true);
9+
// * returns 2: [{0:'Kevin', 1:'van'}, {2: 'Zonneveld'}]
10+
// * example 3: array_chunk({1:'Kevin', 2:'van', 3:'Zonneveld'}, 2);
11+
// * returns 3: [['Kevin', 'van'], ['Zonneveld']]
12+
// * example 4: array_chunk({1:'Kevin', 2:'van', 3:'Zonneveld'}, 2, true);
13+
// * returns 4: [{1: 'Kevin', 2: 'van'}, {3: 'Zonneveld'}]
1414

15-
var x, p = '', i = 0, c = -1, l = input.length || 0, n = [];
15+
var x, p = '', i = 0, c = -1, l = input.length || 0, n = [];
1616

17-
if (size < 1) {
18-
return null;
19-
}
17+
if (size < 1) {
18+
return null;
19+
}
2020

21-
if (Object.prototype.toString.call(input) === '[object Array]') {
22-
if (preserve_keys) {
23-
while (i < l) {
24-
(x = i % size) ? n[c][i] = input[i] : n[++c] = {}, n[c][i] = input[i];
25-
i++;
26-
}
27-
}
28-
else {
29-
while (i < l) {
30-
(x = i % size) ? n[c][x] = input[i] : n[++c] = [input[i]];
31-
i++;
32-
}
33-
}
21+
if (Object.prototype.toString.call(input) === '[object Array]') {
22+
if (preserve_keys) {
23+
while (i < l) {
24+
(x = i % size) ? n[c][i] = input[i] : n[++c] = {}, n[c][i] = input[i];
25+
i++;
26+
}
3427
}
3528
else {
36-
if (preserve_keys) {
37-
for (p in input) {
38-
if (input.hasOwnProperty(p)) {
39-
(x = i % size) ? n[c][p] = input[p] : n[++c] = {}, n[c][p] = input[p];
40-
i++;
41-
}
42-
}
29+
while (i < l) {
30+
(x = i % size) ? n[c][x] = input[i] : n[++c] = [input[i]];
31+
i++;
32+
}
33+
}
34+
}
35+
else {
36+
if (preserve_keys) {
37+
for (p in input) {
38+
if (input.hasOwnProperty(p)) {
39+
(x = i % size) ? n[c][p] = input[p] : n[++c] = {}, n[c][p] = input[p];
40+
i++;
4341
}
44-
else {
45-
for (p in input) {
46-
if (input.hasOwnProperty(p)) {
47-
(x = i % size) ? n[c][x] = input[p] : n[++c] = [input[p]];
48-
i++;
49-
}
50-
}
42+
}
43+
}
44+
else {
45+
for (p in input) {
46+
if (input.hasOwnProperty(p)) {
47+
(x = i % size) ? n[c][x] = input[p] : n[++c] = [input[p]];
48+
i++;
5149
}
50+
}
5251
}
53-
return n;
52+
}
53+
return n;
5454
}

functions/array/array_combine.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
function array_combine (keys, values) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4-
// + improved by: Brett Zamir (http://brett-zamir.me)
5-
// * example 1: array_combine([0,1,2], ['kevin','van','zonneveld']);
6-
// * returns 1: {0: 'kevin', 1: 'van', 2: 'zonneveld'}
7-
var new_array = {},
8-
keycount = keys && keys.length,
9-
i = 0;
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4+
// + improved by: Brett Zamir (http://brett-zamir.me)
5+
// * example 1: array_combine([0,1,2], ['kevin','van','zonneveld']);
6+
// * returns 1: {0: 'kevin', 1: 'van', 2: 'zonneveld'}
7+
var new_array = {},
8+
keycount = keys && keys.length,
9+
i = 0;
1010

11-
// input sanitation
12-
if (typeof keys !== 'object' || typeof values !== 'object' || // Only accept arrays or array-like objects
13-
typeof keycount !== 'number' || typeof values.length !== 'number' || !keycount) { // Require arrays to have a count
14-
return false;
15-
}
11+
// input sanitation
12+
if (typeof keys !== 'object' || typeof values !== 'object' || // Only accept arrays or array-like objects
13+
typeof keycount !== 'number' || typeof values.length !== 'number' || !keycount) { // Require arrays to have a count
14+
return false;
15+
}
1616

17-
// number of elements does not match
18-
if (keycount != values.length) {
19-
return false;
20-
}
17+
// number of elements does not match
18+
if (keycount != values.length) {
19+
return false;
20+
}
2121

22-
for (i = 0; i < keycount; i++) {
23-
new_array[keys[i]] = values[i];
24-
}
22+
for (i = 0; i < keycount; i++) {
23+
new_array[keys[i]] = values[i];
24+
}
2525

26-
return new_array;
26+
return new_array;
2727
}
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
function array_count_values (array) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Ates Goral (http://magnetiq.com)
4-
// + namespaced by: Michael White (http://getsprink.com)
5-
// + input by: sankai
6-
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
7-
// + input by: Shingo
8-
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
9-
// * example 1: array_count_values([ 3, 5, 3, "foo", "bar", "foo" ]);
10-
// * returns 1: {3:2, 5:1, "foo":2, "bar":1}
11-
// * example 2: array_count_values({ p1: 3, p2: 5, p3: 3, p4: "foo", p5: "bar", p6: "foo" });
12-
// * returns 2: {3:2, 5:1, "foo":2, "bar":1}
13-
// * example 3: array_count_values([ true, 4.2, 42, "fubar" ]);
14-
// * returns 3: {42:1, "fubar":1}
15-
var tmp_arr = {},
16-
key = '',
17-
t = '';
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Ates Goral (http://magnetiq.com)
4+
// + namespaced by: Michael White (http://getsprink.com)
5+
// + input by: sankai
6+
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
7+
// + input by: Shingo
8+
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
9+
// * example 1: array_count_values([ 3, 5, 3, "foo", "bar", "foo" ]);
10+
// * returns 1: {3:2, 5:1, "foo":2, "bar":1}
11+
// * example 2: array_count_values({ p1: 3, p2: 5, p3: 3, p4: "foo", p5: "bar", p6: "foo" });
12+
// * returns 2: {3:2, 5:1, "foo":2, "bar":1}
13+
// * example 3: array_count_values([ true, 4.2, 42, "fubar" ]);
14+
// * returns 3: {42:1, "fubar":1}
15+
var tmp_arr = {},
16+
key = '',
17+
t = '';
1818

19-
var __getType = function (obj) {
20-
// Objects are php associative arrays.
21-
var t = typeof obj;
22-
t = t.toLowerCase();
23-
if (t === "object") {
24-
t = "array";
25-
}
26-
return t;
27-
};
19+
var __getType = function (obj) {
20+
// Objects are php associative arrays.
21+
var t = typeof obj;
22+
t = t.toLowerCase();
23+
if (t === "object") {
24+
t = "array";
25+
}
26+
return t;
27+
};
2828

29-
var __countValue = function (value) {
30-
switch (typeof(value)) {
31-
case "number":
32-
if (Math.floor(value) !== value) {
33-
return;
34-
}
35-
// Fall-through
36-
case "string":
37-
if (value in this && this.hasOwnProperty(value)) {
38-
++this[value];
39-
} else {
40-
this[value] = 1;
41-
}
42-
}
43-
};
29+
var __countValue = function (value) {
30+
switch (typeof(value)) {
31+
case "number":
32+
if (Math.floor(value) !== value) {
33+
return;
34+
}
35+
// Fall-through
36+
case "string":
37+
if (value in this && this.hasOwnProperty(value)) {
38+
++this[value];
39+
} else {
40+
this[value] = 1;
41+
}
42+
}
43+
};
4444

45-
t = __getType(array);
46-
if (t === 'array') {
47-
for (key in array) {
48-
if (array.hasOwnProperty(key)) {
49-
__countValue.call(tmp_arr, array[key]);
50-
}
51-
}
45+
t = __getType(array);
46+
if (t === 'array') {
47+
for (key in array) {
48+
if (array.hasOwnProperty(key)) {
49+
__countValue.call(tmp_arr, array[key]);
50+
}
5251
}
53-
return tmp_arr;
52+
}
53+
return tmp_arr;
5454
}

functions/array/array_diff.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
function array_diff (arr1) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4-
// + improved by: Sanjoy Roy
5-
// + revised by: Brett Zamir (http://brett-zamir.me)
6-
// * example 1: array_diff(['Kevin', 'van', 'Zonneveld'], ['van', 'Zonneveld']);
7-
// * returns 1: {0:'Kevin'}
8-
var retArr = {},
9-
argl = arguments.length,
10-
k1 = '',
11-
i = 1,
12-
k = '',
13-
arr = {};
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4+
// + improved by: Sanjoy Roy
5+
// + revised by: Brett Zamir (http://brett-zamir.me)
6+
// * example 1: array_diff(['Kevin', 'van', 'Zonneveld'], ['van', 'Zonneveld']);
7+
// * returns 1: {0:'Kevin'}
8+
var retArr = {},
9+
argl = arguments.length,
10+
k1 = '',
11+
i = 1,
12+
k = '',
13+
arr = {};
1414

15-
arr1keys: for (k1 in arr1) {
16-
for (i = 1; i < argl; i++) {
17-
arr = arguments[i];
18-
for (k in arr) {
19-
if (arr[k] === arr1[k1]) {
20-
// If it reaches here, it was found in at least one array, so try next value
21-
continue arr1keys;
22-
}
23-
}
24-
retArr[k1] = arr1[k1];
15+
arr1keys: for (k1 in arr1) {
16+
for (i = 1; i < argl; i++) {
17+
arr = arguments[i];
18+
for (k in arr) {
19+
if (arr[k] === arr1[k1]) {
20+
// If it reaches here, it was found in at least one array, so try next value
21+
continue arr1keys;
2522
}
23+
}
24+
retArr[k1] = arr1[k1];
2625
}
26+
}
2727

28-
return retArr;
28+
return retArr;
2929
}

0 commit comments

Comments
 (0)