Skip to content

Commit 6a20250

Browse files
authored
Update PowerArray.js
Bugfixing
1 parent f16d095 commit 6a20250

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

PowerArray.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ if (mainContainer.pa && console && console.warn) {
15281528

15291529

15301530
if (typeOfWhereConditions === 'string' || typeOfWhereConditions === 'number') {
1531-
tmp = pa.paWhereHelper.ProcessConditionObject.call(this, EqualTo3(whereConditions), keepOrder, false, justFirst, justIndexes);
1531+
tmp = pa.paWhereHelper.ProcessConditionObject.call(this, typeOfWhereConditions === 'string' ? EqualTo3(whereConditions) : EqualTo2(whereConditions), keepOrder, false, justFirst, justIndexes);
15321532
if (justFirst)
15331533
return tmp;
15341534
result.push.apply(result, tmp);
@@ -1742,7 +1742,7 @@ if (mainContainer.pa && console && console.warn) {
17421742
arr.split(0) will return = [[1,2,3,4],[2,3,6,3],[5,2,5,54],[2,6]]
17431743
*/
17441744
Split: function (whereConditions) {
1745-
var result = [], nextStartIdx = 0;
1745+
var result = [];
17461746
var allIndexes = this.AllIndexes(whereConditions);
17471747
var prevIndexVal = -1;
17481748
allIndexes.RunEach((val, i) => {
@@ -1787,16 +1787,23 @@ if (mainContainer.pa && console && console.warn) {
17871787
mainContainer.pa.Sort._validSortConfigStrings = validSortingConf;
17881788
mainContainer.Sort = mainContainer.pa.Sort;
17891789

1790-
var paArray = function (array) {
1790+
var paArray = function (arrayCandidate) {
17911791

17921792
var newArray;
1793-
if (array.paIsArray) {
1794-
newArray = array.slice(0);
1793+
if (arrayCandidate.paIsArray) {
1794+
newArray = arrayCandidate.slice(0);
17951795
} else {
1796-
if (pa.utils.GetTypeOf(array) === pa.utils.DataTypes.String) {
1797-
newArray = array.split('');
1796+
if (pa.utils.GetTypeOf(arrayCandidate) === pa.utils.DataTypes.String) {
1797+
newArray = arrayCandidate.split('');
17981798
} else {
1799-
throw new Error('PowerArray => paArray error => Invalid data type passed to pa() or paArray() function. Allowed are arrays and strings');
1799+
if (Buffer) {
1800+
//we're in nodejs!
1801+
if (Buffer.isBuffer(arrayCandidate)) {
1802+
newArray = Array.prototype.slice.call(arrayCandidate);
1803+
}
1804+
} else {
1805+
throw new Error('PowerArray => paArray error => Invalid data type passed to pa() or paArray() function. Allowed are arrays and strings');
1806+
}
18001807
}
18011808
}
18021809

0 commit comments

Comments
 (0)