alasql 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/alasql-cli.js +1 -1
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +1 -1
- package/dist/alasql.fs.js +208 -202
- package/dist/alasql.js +208 -202
- package/dist/alasql.min.js +3 -3
- package/package.json +1 -1
package/dist/alasql.fs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v2.1.
|
|
1
|
+
//! AlaSQL v2.1.9 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 2.1.
|
|
4
|
+
@version 2.1.9
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
|
|
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
|
|
|
142
142
|
Current version of alasql
|
|
143
143
|
@constant {string}
|
|
144
144
|
*/
|
|
145
|
-
alasql.version = '2.1.
|
|
145
|
+
alasql.version = '2.1.9';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -3178,64 +3178,64 @@ alasql.pretty = function (sql, flag) {
|
|
|
3178
3178
|
var utils = (alasql.utils = {});
|
|
3179
3179
|
|
|
3180
3180
|
/**
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3181
|
+
Convert NaN to undefined
|
|
3182
|
+
@function
|
|
3183
|
+
@param {string} s JavaScript string to be modified
|
|
3184
|
+
@return {string} Covered expression
|
|
3185
3185
|
|
|
3186
|
-
|
|
3186
|
+
@example
|
|
3187
3187
|
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3188
|
+
123 => 123
|
|
3189
|
+
undefined => undefined
|
|
3190
|
+
NaN => undefined
|
|
3191
3191
|
|
|
3192
|
-
|
|
3192
|
+
*/
|
|
3193
3193
|
function n2u(s) {
|
|
3194
3194
|
return '(y=' + s + ',y===y?y:undefined)';
|
|
3195
3195
|
}
|
|
3196
3196
|
|
|
3197
3197
|
/**
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3198
|
+
Return undefined if s undefined
|
|
3199
|
+
@param {string} s JavaScript string to be modified
|
|
3200
|
+
@return {string} Covered expression
|
|
3201
3201
|
|
|
3202
|
-
|
|
3202
|
+
@example
|
|
3203
3203
|
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3204
|
+
123,a => a
|
|
3205
|
+
undefined,a => undefined
|
|
3206
|
+
NaN,a => undefined
|
|
3207
3207
|
|
|
3208
|
-
|
|
3208
|
+
*/
|
|
3209
3209
|
function und(s, r) {
|
|
3210
3210
|
return '(y=' + s + ',typeof y=="undefined"?undefined:' + r + ')';
|
|
3211
3211
|
}
|
|
3212
3212
|
|
|
3213
3213
|
/**
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3214
|
+
Return always true. Stub for non-ecisting WHERE clause, because is faster then if(whenrfn) whenfn()
|
|
3215
|
+
@function
|
|
3216
|
+
@return {boolean} Always true
|
|
3217
|
+
*/
|
|
3218
3218
|
function returnTrue() {
|
|
3219
3219
|
return true;
|
|
3220
3220
|
}
|
|
3221
3221
|
|
|
3222
3222
|
/**
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3223
|
+
Return undefined. Stub for non-ecisting WHERE clause, because is faster then if(whenrfn) whenfn()
|
|
3224
|
+
@function
|
|
3225
|
+
@return {undefined} Always undefined
|
|
3226
|
+
*/
|
|
3227
3227
|
function returnUndefined() {}
|
|
3228
3228
|
|
|
3229
3229
|
/**
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3230
|
+
Escape string
|
|
3231
|
+
@function
|
|
3232
|
+
@param {string} s Source string
|
|
3233
|
+
@return {string} Escaped string
|
|
3234
|
+
@example
|
|
3235
3235
|
|
|
3236
|
-
|
|
3236
|
+
Pit\er's => Pit\\er\'s
|
|
3237
3237
|
|
|
3238
|
-
|
|
3238
|
+
*/
|
|
3239
3239
|
// based on joliss/js-string-escape
|
|
3240
3240
|
var escapeq = (utils.escapeq = function (s) {
|
|
3241
3241
|
|
|
@@ -3262,49 +3262,49 @@ var escapeq = (utils.escapeq = function (s) {
|
|
|
3262
3262
|
});
|
|
3263
3263
|
|
|
3264
3264
|
/**
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3265
|
+
Double quotes for SQL statements
|
|
3266
|
+
@param {string} s Source string
|
|
3267
|
+
@return {string} Escaped string
|
|
3268
3268
|
|
|
3269
|
-
|
|
3269
|
+
@example
|
|
3270
3270
|
|
|
3271
|
-
|
|
3271
|
+
Piter's => Piter''s
|
|
3272
3272
|
|
|
3273
|
-
|
|
3273
|
+
*/
|
|
3274
3274
|
var escapeqq = (utils.undoubleq = function (s) {
|
|
3275
3275
|
return s.replace(/(\')/g, "''");
|
|
3276
3276
|
});
|
|
3277
3277
|
|
|
3278
3278
|
/**
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3279
|
+
Replace double quotes with single quote
|
|
3280
|
+
@param {string} s Source string
|
|
3281
|
+
@return {string} Replaced string
|
|
3282
|
+
@example
|
|
3283
3283
|
|
|
3284
|
-
|
|
3284
|
+
Piter''s => Piter's
|
|
3285
3285
|
|
|
3286
|
-
|
|
3286
|
+
*/
|
|
3287
3287
|
var doubleq = (utils.doubleq = function (s) {
|
|
3288
3288
|
return s.replace(/(\'\')/g, "\\'");
|
|
3289
3289
|
});
|
|
3290
3290
|
|
|
3291
3291
|
/**
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3292
|
+
Replace sigle quote to escaped single quote
|
|
3293
|
+
@param {string} s Source string
|
|
3294
|
+
@return {string} Replaced string
|
|
3295
3295
|
|
|
3296
|
-
|
|
3296
|
+
@todo Chack this functions
|
|
3297
3297
|
|
|
3298
|
-
|
|
3298
|
+
*/
|
|
3299
3299
|
var doubleqq = (utils.doubleqq = function (s) {
|
|
3300
3300
|
return s.replace(/\'/g, "'");
|
|
3301
3301
|
});
|
|
3302
3302
|
|
|
3303
3303
|
/**
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3304
|
+
Cut BOM first character for UTF-8 files (for merging two files)
|
|
3305
|
+
@param {string} s Source string
|
|
3306
|
+
@return {string} Replaced string
|
|
3307
|
+
*/
|
|
3308
3308
|
|
|
3309
3309
|
var cutbom = function (s) {
|
|
3310
3310
|
if (s[0] === String.fromCharCode(65279)) {
|
|
@@ -3314,10 +3314,10 @@ var cutbom = function (s) {
|
|
|
3314
3314
|
};
|
|
3315
3315
|
|
|
3316
3316
|
/**
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3317
|
+
Get the global scope
|
|
3318
|
+
Inspired by System.global
|
|
3319
|
+
@return {object} The global scope
|
|
3320
|
+
*/
|
|
3321
3321
|
utils.global = (function () {
|
|
3322
3322
|
if (typeof self !== 'undefined') {
|
|
3323
3323
|
return self;
|
|
@@ -3332,18 +3332,18 @@ utils.global = (function () {
|
|
|
3332
3332
|
})();
|
|
3333
3333
|
|
|
3334
3334
|
/**
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3335
|
+
Find out if a function is native to the enviroment
|
|
3336
|
+
@param {function} Function to check
|
|
3337
|
+
@return {boolean} True if function is native
|
|
3338
|
+
*/
|
|
3339
3339
|
var isNativeFunction = (utils.isNativeFunction = function (fn) {
|
|
3340
3340
|
return typeof fn === 'function' && !!~fn.toString().indexOf('[native code]');
|
|
3341
3341
|
});
|
|
3342
3342
|
|
|
3343
3343
|
/**
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3344
|
+
Find out if code is running in a web worker enviroment
|
|
3345
|
+
@return {boolean} True if code is running in a web worker enviroment
|
|
3346
|
+
*/
|
|
3347
3347
|
utils.isWebWorker = (function () {
|
|
3348
3348
|
try {
|
|
3349
3349
|
var importScripts = utils.global.importScripts;
|
|
@@ -3354,9 +3354,9 @@ utils.isWebWorker = (function () {
|
|
|
3354
3354
|
})();
|
|
3355
3355
|
|
|
3356
3356
|
/**
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3357
|
+
Find out if code is running in a node enviroment
|
|
3358
|
+
@return {boolean} True if code is running in a node enviroment
|
|
3359
|
+
*/
|
|
3360
3360
|
utils.isNode = (function () {
|
|
3361
3361
|
try {
|
|
3362
3362
|
return utils.isNativeFunction(utils.global.process.reallyExit);
|
|
@@ -3366,9 +3366,9 @@ utils.isNode = (function () {
|
|
|
3366
3366
|
})();
|
|
3367
3367
|
|
|
3368
3368
|
/**
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3369
|
+
Find out if code is running in a browser enviroment
|
|
3370
|
+
@return {boolean} True if code is running in a browser enviroment
|
|
3371
|
+
*/
|
|
3372
3372
|
utils.isBrowser = (function () {
|
|
3373
3373
|
try {
|
|
3374
3374
|
return utils.isNativeFunction(utils.global.location.reload);
|
|
@@ -3378,17 +3378,17 @@ utils.isBrowser = (function () {
|
|
|
3378
3378
|
})();
|
|
3379
3379
|
|
|
3380
3380
|
/**
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3381
|
+
Find out if code is running in a browser with a browserify setup
|
|
3382
|
+
@return {boolean} True if code is running in a browser with a browserify setup
|
|
3383
|
+
*/
|
|
3384
3384
|
utils.isBrowserify = (function () {
|
|
3385
3385
|
return utils.isBrowser && typeof process !== 'undefined' && process.browser;
|
|
3386
3386
|
})();
|
|
3387
3387
|
|
|
3388
3388
|
/**
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3389
|
+
Find out if code is running in a browser with a requireJS setup
|
|
3390
|
+
@return {boolean} True if code is running in a browser with a requireJS setup
|
|
3391
|
+
*/
|
|
3392
3392
|
utils.isRequireJS = (function () {
|
|
3393
3393
|
return (
|
|
3394
3394
|
utils.isBrowser && typeof require === 'function' && typeof require.specified === 'function'
|
|
@@ -3396,37 +3396,37 @@ utils.isRequireJS = (function () {
|
|
|
3396
3396
|
})();
|
|
3397
3397
|
|
|
3398
3398
|
/**
|
|
3399
|
-
|
|
3400
|
-
|
|
3399
|
+
Find out if code is running with Meteor in the enviroment
|
|
3400
|
+
@return {boolean} True if code is running with Meteor in the enviroment
|
|
3401
3401
|
|
|
3402
|
-
|
|
3403
|
-
|
|
3402
|
+
@todo Find out if this is the best way to do this
|
|
3403
|
+
*/
|
|
3404
3404
|
utils.isMeteor = (function () {
|
|
3405
3405
|
return typeof Meteor !== 'undefined' && Meteor.release;
|
|
3406
3406
|
})();
|
|
3407
3407
|
|
|
3408
3408
|
/**
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3409
|
+
Find out if code is running on a Meteor client
|
|
3410
|
+
@return {boolean} True if code is running on a Meteor client
|
|
3411
|
+
*/
|
|
3412
3412
|
utils.isMeteorClient = utils.isMeteorClient = (function () {
|
|
3413
3413
|
return utils.isMeteor && Meteor.isClient;
|
|
3414
3414
|
})();
|
|
3415
3415
|
|
|
3416
3416
|
/**
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3417
|
+
Find out if code is running on a Meteor server
|
|
3418
|
+
@return {boolean} True if code is running on a Meteor server
|
|
3419
|
+
*/
|
|
3420
3420
|
utils.isMeteorServer = (function () {
|
|
3421
3421
|
return utils.isMeteor && Meteor.isServer;
|
|
3422
3422
|
})();
|
|
3423
3423
|
|
|
3424
3424
|
/**
|
|
3425
|
-
|
|
3426
|
-
|
|
3425
|
+
Find out code is running in a cordovar enviroment
|
|
3426
|
+
@return {boolean} True if code is running in a web worker enviroment
|
|
3427
3427
|
|
|
3428
|
-
|
|
3429
|
-
|
|
3428
|
+
@todo Find out if this is the best way to do this
|
|
3429
|
+
*/
|
|
3430
3430
|
utils.isCordova = (function () {
|
|
3431
3431
|
return typeof cordova === 'object';
|
|
3432
3432
|
})();
|
|
@@ -3453,16 +3453,16 @@ utils.isArray = function (obj) {
|
|
|
3453
3453
|
return '[object Array]' === Object.prototype.toString.call(obj);
|
|
3454
3454
|
};
|
|
3455
3455
|
/**
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3456
|
+
Load text file from anywhere
|
|
3457
|
+
@param {string|object} path File path or HTML event
|
|
3458
|
+
@param {boolean} asy True - async call, false - sync call
|
|
3459
|
+
@param {function} success Success function
|
|
3460
|
+
@param {function} error Error function
|
|
3461
|
+
@return {string} Read data
|
|
3462
|
+
|
|
3463
|
+
@todo Define Event type
|
|
3464
|
+
@todo Smaller if-else structures.
|
|
3465
|
+
*/
|
|
3466
3466
|
var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
3467
3467
|
var data, fs;
|
|
3468
3468
|
if (utils.isNode || utils.isMeteorServer) {
|
|
@@ -3549,16 +3549,16 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3549
3549
|
if (typeof path === 'string') {
|
|
3550
3550
|
// For browser read from tag
|
|
3551
3551
|
/*
|
|
3552
|
-
|
|
3553
|
-
|
|
3552
|
+
SELECT * FROM TXT('#one') -- read data from HTML element with id="one"
|
|
3553
|
+
*/
|
|
3554
3554
|
if (path.substr(0, 1) === '#' && typeof document !== 'undefined') {
|
|
3555
3555
|
data = document.querySelector(path).textContent;
|
|
3556
3556
|
success(data);
|
|
3557
3557
|
} else {
|
|
3558
3558
|
/*
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3559
|
+
Simply read file from HTTP request, like:
|
|
3560
|
+
SELECT * FROM TXT('http://alasql.org/README.md');
|
|
3561
|
+
*/
|
|
3562
3562
|
var xhr = new XMLHttpRequest();
|
|
3563
3563
|
xhr.onreadystatechange = function () {
|
|
3564
3564
|
if (xhr.readyState === 4) {
|
|
@@ -3578,14 +3578,14 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3578
3578
|
}
|
|
3579
3579
|
} else if (path instanceof Event) {
|
|
3580
3580
|
/*
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3581
|
+
For browser read from files input element
|
|
3582
|
+
<input type="files" onchange="readFile(event)">
|
|
3583
|
+
<script>
|
|
3584
|
+
function readFile(event) {
|
|
3585
|
+
alasql('SELECT * FROM TXT(?)',[event])
|
|
3586
|
+
}
|
|
3587
|
+
</script>
|
|
3588
|
+
*/
|
|
3589
3589
|
/** @type {array} List of files from <input> element */
|
|
3590
3590
|
var files = path.target.files;
|
|
3591
3591
|
/** type {object} */
|
|
@@ -3602,15 +3602,15 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3602
3602
|
});
|
|
3603
3603
|
|
|
3604
3604
|
/**
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3605
|
+
@function Load binary file from anywhere
|
|
3606
|
+
@param {string} path File path
|
|
3607
|
+
@param {boolean} asy True - async call, false - sync call
|
|
3608
|
+
@param {function} success Success function
|
|
3609
|
+
@param {function} error Error function
|
|
3610
|
+
@return 1 for Async, data - for sync version
|
|
3611
|
+
|
|
3612
|
+
@todo merge functionality from loadFile and LoadBinaryFile
|
|
3613
|
+
*/
|
|
3614
3614
|
|
|
3615
3615
|
var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
3616
3616
|
path,
|
|
@@ -3815,12 +3815,12 @@ var fileExists = (utils.fileExists = function (path, cb) {
|
|
|
3815
3815
|
});
|
|
3816
3816
|
|
|
3817
3817
|
/**
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3818
|
+
Save text file from anywhere
|
|
3819
|
+
@param {string} path File path
|
|
3820
|
+
@param {array} data Data object
|
|
3821
|
+
@param {function} cb Callback
|
|
3822
|
+
@param {object=} opts
|
|
3823
|
+
*/
|
|
3824
3824
|
|
|
3825
3825
|
var saveFile = (utils.saveFile = function (path, data, cb, opts) {
|
|
3826
3826
|
var res = 1;
|
|
@@ -3903,21 +3903,21 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
|
|
|
3903
3903
|
});
|
|
3904
3904
|
|
|
3905
3905
|
/**
|
|
3906
|
-
|
|
3907
|
-
|
|
3906
|
+
@function Is this IE9
|
|
3907
|
+
@return {boolean} True for IE9 and false for other browsers
|
|
3908
3908
|
|
|
3909
|
-
|
|
3910
|
-
|
|
3909
|
+
For IE9 compatibility issues
|
|
3910
|
+
*/
|
|
3911
3911
|
function isIE() {
|
|
3912
3912
|
var myNav = navigator.userAgent.toLowerCase();
|
|
3913
3913
|
return myNav.indexOf('msie') !== -1 ? parseInt(myNav.split('msie')[1]) : false;
|
|
3914
3914
|
}
|
|
3915
3915
|
|
|
3916
3916
|
/**
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3917
|
+
@function Hash a string to signed integer
|
|
3918
|
+
@param {string} source string
|
|
3919
|
+
@return {integer} hash number
|
|
3920
|
+
*/
|
|
3921
3921
|
|
|
3922
3922
|
// FNV-1a inspired hashing
|
|
3923
3923
|
var hash = (utils.hash = function (str) {
|
|
@@ -3931,12 +3931,12 @@ var hash = (utils.hash = function (str) {
|
|
|
3931
3931
|
});
|
|
3932
3932
|
|
|
3933
3933
|
/**
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3934
|
+
Union arrays
|
|
3935
|
+
@function
|
|
3936
|
+
@param {array} a
|
|
3937
|
+
@param {array} b
|
|
3938
|
+
@return {array}
|
|
3939
|
+
*/
|
|
3940
3940
|
var arrayUnion = (utils.arrayUnion = function (a, b) {
|
|
3941
3941
|
var r = b.slice(0);
|
|
3942
3942
|
a.forEach(function (i) {
|
|
@@ -3948,8 +3948,8 @@ var arrayUnion = (utils.arrayUnion = function (a, b) {
|
|
|
3948
3948
|
});
|
|
3949
3949
|
|
|
3950
3950
|
/**
|
|
3951
|
-
|
|
3952
|
-
|
|
3951
|
+
Array Difference
|
|
3952
|
+
*/
|
|
3953
3953
|
var arrayDiff = (utils.arrayDiff = function (a, b) {
|
|
3954
3954
|
return a.filter(function (i) {
|
|
3955
3955
|
return b.indexOf(i) < 0;
|
|
@@ -3957,8 +3957,8 @@ var arrayDiff = (utils.arrayDiff = function (a, b) {
|
|
|
3957
3957
|
});
|
|
3958
3958
|
|
|
3959
3959
|
/**
|
|
3960
|
-
|
|
3961
|
-
|
|
3960
|
+
Arrays deep intersect (with records)
|
|
3961
|
+
*/
|
|
3962
3962
|
var arrayIntersect = (utils.arrayIntersect = function (a, b) {
|
|
3963
3963
|
var r = [];
|
|
3964
3964
|
a.forEach(function (ai) {
|
|
@@ -3976,8 +3976,8 @@ var arrayIntersect = (utils.arrayIntersect = function (a, b) {
|
|
|
3976
3976
|
});
|
|
3977
3977
|
|
|
3978
3978
|
/**
|
|
3979
|
-
|
|
3980
|
-
|
|
3979
|
+
Arrays deep union (with records)
|
|
3980
|
+
*/
|
|
3981
3981
|
var arrayUnionDeep = (utils.arrayUnionDeep = function (a, b) {
|
|
3982
3982
|
var r = b.slice(0);
|
|
3983
3983
|
a.forEach(function (ai) {
|
|
@@ -3996,8 +3996,8 @@ var arrayUnionDeep = (utils.arrayUnionDeep = function (a, b) {
|
|
|
3996
3996
|
});
|
|
3997
3997
|
|
|
3998
3998
|
/**
|
|
3999
|
-
|
|
4000
|
-
|
|
3999
|
+
Arrays deep union (with records)
|
|
4000
|
+
*/
|
|
4001
4001
|
var arrayExceptDeep = (utils.arrayExceptDeep = function (a, b) {
|
|
4002
4002
|
var r = [];
|
|
4003
4003
|
a.forEach(function (ai) {
|
|
@@ -4016,8 +4016,8 @@ var arrayExceptDeep = (utils.arrayExceptDeep = function (a, b) {
|
|
|
4016
4016
|
});
|
|
4017
4017
|
|
|
4018
4018
|
/**
|
|
4019
|
-
|
|
4020
|
-
|
|
4019
|
+
Arrays deep intersect (with records)
|
|
4020
|
+
*/
|
|
4021
4021
|
var arrayIntersectDeep = (utils.arrayIntersectDeep = function (a, b) {
|
|
4022
4022
|
var r = [];
|
|
4023
4023
|
a.forEach(function (ai) {
|
|
@@ -4036,8 +4036,8 @@ var arrayIntersectDeep = (utils.arrayIntersectDeep = function (a, b) {
|
|
|
4036
4036
|
});
|
|
4037
4037
|
|
|
4038
4038
|
/**
|
|
4039
|
-
|
|
4040
|
-
|
|
4039
|
+
Deep clone objects
|
|
4040
|
+
*/
|
|
4041
4041
|
var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
4042
4042
|
if (null === obj || typeof obj !== 'object') {
|
|
4043
4043
|
return obj;
|
|
@@ -4055,23 +4055,23 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
|
4055
4055
|
return +obj;
|
|
4056
4056
|
}
|
|
4057
4057
|
|
|
4058
|
-
var temp = obj.constructor(); // changed
|
|
4058
|
+
var temp = (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
|
|
4059
4059
|
|
|
4060
4060
|
for (var key in obj) {
|
|
4061
4061
|
if (obj.hasOwnProperty(key)) {
|
|
4062
|
-
temp[key] = cloneDeep(obj[key]);
|
|
4062
|
+
/* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
|
|
4063
4063
|
}
|
|
4064
4064
|
}
|
|
4065
4065
|
return temp;
|
|
4066
4066
|
});
|
|
4067
4067
|
|
|
4068
4068
|
/**
|
|
4069
|
-
|
|
4070
|
-
|
|
4069
|
+
Check equality of objects
|
|
4070
|
+
*/
|
|
4071
4071
|
|
|
4072
4072
|
/**
|
|
4073
|
-
|
|
4074
|
-
|
|
4073
|
+
Compare two objects in deep
|
|
4074
|
+
*/
|
|
4075
4075
|
var deepEqual = (utils.deepEqual = function (x, y) {
|
|
4076
4076
|
if (x === y) {
|
|
4077
4077
|
return true;
|
|
@@ -4092,10 +4092,10 @@ var deepEqual = (utils.deepEqual = function (x, y) {
|
|
|
4092
4092
|
return false;
|
|
4093
4093
|
});
|
|
4094
4094
|
/**
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4095
|
+
Array with distinct records
|
|
4096
|
+
@param {array} data
|
|
4097
|
+
@return {array}
|
|
4098
|
+
*/
|
|
4099
4099
|
var distinctArray = (utils.distinctArray = function (data) {
|
|
4100
4100
|
var uniq = {};
|
|
4101
4101
|
// TODO: Speedup, because Object.keys is slow
|
|
@@ -4121,17 +4121,17 @@ var distinctArray = (utils.distinctArray = function (data) {
|
|
|
4121
4121
|
});
|
|
4122
4122
|
|
|
4123
4123
|
/**
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4124
|
+
Extend object a with properties of b
|
|
4125
|
+
@function
|
|
4126
|
+
@param {object} a
|
|
4127
|
+
@param {object} b
|
|
4128
|
+
@return {object}
|
|
4129
|
+
*/
|
|
4130
4130
|
var extend = (utils.extend = function extend(a, b) {
|
|
4131
4131
|
a = a || {};
|
|
4132
4132
|
for (var key in b) {
|
|
4133
4133
|
if (b.hasOwnProperty(key)) {
|
|
4134
|
-
a[key] = b[key];
|
|
4134
|
+
/* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
|
|
4135
4135
|
}
|
|
4136
4136
|
}
|
|
4137
4137
|
return a;
|
|
@@ -4147,8 +4147,8 @@ var getValueOf = (utils.getValueOf = function (val) {
|
|
|
4147
4147
|
});
|
|
4148
4148
|
|
|
4149
4149
|
/**
|
|
4150
|
-
|
|
4151
|
-
|
|
4150
|
+
Flat array by first row
|
|
4151
|
+
*/
|
|
4152
4152
|
var flatArray = (utils.flatArray = function (a) {
|
|
4153
4153
|
|
|
4154
4154
|
if (!a || 0 === a.length) {
|
|
@@ -4172,8 +4172,8 @@ var flatArray = (utils.flatArray = function (a) {
|
|
|
4172
4172
|
});
|
|
4173
4173
|
|
|
4174
4174
|
/**
|
|
4175
|
-
|
|
4176
|
-
|
|
4175
|
+
Convert array of objects to array of arrays
|
|
4176
|
+
*/
|
|
4177
4177
|
var arrayOfArrays = (utils.arrayOfArrays = function (a) {
|
|
4178
4178
|
return a.map(function (aa) {
|
|
4179
4179
|
var ar = [];
|
|
@@ -4191,12 +4191,18 @@ if (!Array.isArray) {
|
|
|
4191
4191
|
}
|
|
4192
4192
|
|
|
4193
4193
|
/**
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4194
|
+
Excel:convert number to Excel column, like 1 => 'A'
|
|
4195
|
+
@param {integer} i Column number, starting with 0
|
|
4196
|
+
@return {string} Column name, starting with 'A'
|
|
4197
|
+
*/
|
|
4198
4198
|
|
|
4199
4199
|
var xlsnc = (utils.xlsnc = function (i) {
|
|
4200
|
+
var first = '';
|
|
4201
|
+
if (i > 701) {
|
|
4202
|
+
let x = (((i - 26) / (26 * 26)) | 0) - 1;
|
|
4203
|
+
first = String.fromCharCode(65 + (x % 26));
|
|
4204
|
+
i = i % (26 * 26);
|
|
4205
|
+
}
|
|
4200
4206
|
var addr = String.fromCharCode(65 + (i % 26));
|
|
4201
4207
|
if (i >= 26) {
|
|
4202
4208
|
i = ((i / 26) | 0) - 1;
|
|
@@ -4206,14 +4212,14 @@ var xlsnc = (utils.xlsnc = function (i) {
|
|
|
4206
4212
|
addr = String.fromCharCode(65 + (i % 26)) + addr;
|
|
4207
4213
|
}
|
|
4208
4214
|
}
|
|
4209
|
-
return addr;
|
|
4215
|
+
return first + addr;
|
|
4210
4216
|
});
|
|
4211
4217
|
|
|
4212
4218
|
/**
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4219
|
+
Excel:conver Excel column name to number
|
|
4220
|
+
@param {string} s Column number, like 'A' or 'BE'
|
|
4221
|
+
@return {string} Column name, starting with 0
|
|
4222
|
+
*/
|
|
4217
4223
|
var xlscn = (utils.xlscn = function (s) {
|
|
4218
4224
|
var n = s.charCodeAt(0) - 65;
|
|
4219
4225
|
if (s.length > 1) {
|
|
@@ -4234,12 +4240,12 @@ var domEmptyChildren = (utils.domEmptyChildren = function (container) {
|
|
|
4234
4240
|
});
|
|
4235
4241
|
|
|
4236
4242
|
/**
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
+
SQL LIKE emulation
|
|
4244
|
+
@parameter {string} pattern Search pattern
|
|
4245
|
+
@parameter {string} value Searched value
|
|
4246
|
+
@parameter {string} escape Escape character (optional)
|
|
4247
|
+
@return {boolean} If value LIKE pattern ESCAPE escape
|
|
4248
|
+
*/
|
|
4243
4249
|
|
|
4244
4250
|
var like = (utils.like = function (pattern, value, escape) {
|
|
4245
4251
|
// Verify escape character
|
|
@@ -4310,9 +4316,9 @@ utils.glob = function (value, pattern) {
|
|
|
4310
4316
|
};
|
|
4311
4317
|
|
|
4312
4318
|
/**
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4319
|
+
Get path of alasql.js
|
|
4320
|
+
@todo Rewrite and simplify the code. Review, is this function is required separately
|
|
4321
|
+
*/
|
|
4316
4322
|
utils.findAlaSQLPath = function () {
|
|
4317
4323
|
/** type {string} Path to alasql library and plugins */
|
|
4318
4324
|
|
|
@@ -8689,7 +8695,7 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8689
8695
|
aft2 = '';
|
|
8690
8696
|
|
|
8691
8697
|
if (typeof query.groupStar !== 'undefined') {
|
|
8692
|
-
aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
|
|
8698
|
+
aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
|
|
8693
8699
|
}
|
|
8694
8700
|
|
|
8695
8701
|
/*
|
|
@@ -9011,7 +9017,7 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9011
9017
|
} else {
|
|
9012
9018
|
|
|
9013
9019
|
// if column not exist, then copy all
|
|
9014
|
-
sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
|
|
9020
|
+
sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
|
|
9015
9021
|
|
|
9016
9022
|
query.dirtyColumns = true;
|
|
9017
9023
|
}
|
|
@@ -9340,10 +9346,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
|
|
|
9340
9346
|
self.columns.forEach(function (col) {
|
|
9341
9347
|
|
|
9342
9348
|
if (col instanceof yy.Column && col.columnid === '*') {
|
|
9343
|
-
// s += 'for(var k in g){r[k]=g[k]};';
|
|
9349
|
+
// s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9344
9350
|
// s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
|
|
9345
9351
|
|
|
9346
|
-
s += 'for(var k in g) {r[k]=g[k]};';
|
|
9352
|
+
s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9347
9353
|
return '';
|
|
9348
9354
|
|
|
9349
9355
|
} else {
|
|
@@ -12630,7 +12636,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12630
12636
|
|
|
12631
12637
|
table.update(
|
|
12632
12638
|
function (t) {
|
|
12633
|
-
for (var f in r) t[f] = r[f];
|
|
12639
|
+
for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
|
|
12634
12640
|
},
|
|
12635
12641
|
table.data.indexOf(toreplace),
|
|
12636
12642
|
params
|
|
@@ -14204,7 +14210,7 @@ yy.Insert.prototype.compile = function (databaseid) {
|
|
|
14204
14210
|
});
|
|
14205
14211
|
} else {
|
|
14206
14212
|
|
|
14207
|
-
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
|
|
14213
|
+
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
|
|
14208
14214
|
sw = JSONtoJS(values);
|
|
14209
14215
|
}
|
|
14210
14216
|
}
|