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.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) {
|
|
@@ -3547,16 +3547,16 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3547
3547
|
if (typeof path === 'string') {
|
|
3548
3548
|
// For browser read from tag
|
|
3549
3549
|
/*
|
|
3550
|
-
|
|
3551
|
-
|
|
3550
|
+
SELECT * FROM TXT('#one') -- read data from HTML element with id="one"
|
|
3551
|
+
*/
|
|
3552
3552
|
if (path.substr(0, 1) === '#' && typeof document !== 'undefined') {
|
|
3553
3553
|
data = document.querySelector(path).textContent;
|
|
3554
3554
|
success(data);
|
|
3555
3555
|
} else {
|
|
3556
3556
|
/*
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3557
|
+
Simply read file from HTTP request, like:
|
|
3558
|
+
SELECT * FROM TXT('http://alasql.org/README.md');
|
|
3559
|
+
*/
|
|
3560
3560
|
var xhr = new XMLHttpRequest();
|
|
3561
3561
|
xhr.onreadystatechange = function () {
|
|
3562
3562
|
if (xhr.readyState === 4) {
|
|
@@ -3576,14 +3576,14 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3576
3576
|
}
|
|
3577
3577
|
} else if (path instanceof Event) {
|
|
3578
3578
|
/*
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3579
|
+
For browser read from files input element
|
|
3580
|
+
<input type="files" onchange="readFile(event)">
|
|
3581
|
+
<script>
|
|
3582
|
+
function readFile(event) {
|
|
3583
|
+
alasql('SELECT * FROM TXT(?)',[event])
|
|
3584
|
+
}
|
|
3585
|
+
</script>
|
|
3586
|
+
*/
|
|
3587
3587
|
/** @type {array} List of files from <input> element */
|
|
3588
3588
|
var files = path.target.files;
|
|
3589
3589
|
/** type {object} */
|
|
@@ -3600,15 +3600,15 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3600
3600
|
});
|
|
3601
3601
|
|
|
3602
3602
|
/**
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3603
|
+
@function Load binary file from anywhere
|
|
3604
|
+
@param {string} path File path
|
|
3605
|
+
@param {boolean} asy True - async call, false - sync call
|
|
3606
|
+
@param {function} success Success function
|
|
3607
|
+
@param {function} error Error function
|
|
3608
|
+
@return 1 for Async, data - for sync version
|
|
3609
|
+
|
|
3610
|
+
@todo merge functionality from loadFile and LoadBinaryFile
|
|
3611
|
+
*/
|
|
3612
3612
|
|
|
3613
3613
|
var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
3614
3614
|
path,
|
|
@@ -3808,12 +3808,12 @@ var fileExists = (utils.fileExists = function (path, cb) {
|
|
|
3808
3808
|
});
|
|
3809
3809
|
|
|
3810
3810
|
/**
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3811
|
+
Save text file from anywhere
|
|
3812
|
+
@param {string} path File path
|
|
3813
|
+
@param {array} data Data object
|
|
3814
|
+
@param {function} cb Callback
|
|
3815
|
+
@param {object=} opts
|
|
3816
|
+
*/
|
|
3817
3817
|
|
|
3818
3818
|
var saveFile = (utils.saveFile = function (path, data, cb, opts) {
|
|
3819
3819
|
var res = 1;
|
|
@@ -3895,21 +3895,21 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
|
|
|
3895
3895
|
});
|
|
3896
3896
|
|
|
3897
3897
|
/**
|
|
3898
|
-
|
|
3899
|
-
|
|
3898
|
+
@function Is this IE9
|
|
3899
|
+
@return {boolean} True for IE9 and false for other browsers
|
|
3900
3900
|
|
|
3901
|
-
|
|
3902
|
-
|
|
3901
|
+
For IE9 compatibility issues
|
|
3902
|
+
*/
|
|
3903
3903
|
function isIE() {
|
|
3904
3904
|
var myNav = navigator.userAgent.toLowerCase();
|
|
3905
3905
|
return myNav.indexOf('msie') !== -1 ? parseInt(myNav.split('msie')[1]) : false;
|
|
3906
3906
|
}
|
|
3907
3907
|
|
|
3908
3908
|
/**
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3909
|
+
@function Hash a string to signed integer
|
|
3910
|
+
@param {string} source string
|
|
3911
|
+
@return {integer} hash number
|
|
3912
|
+
*/
|
|
3913
3913
|
|
|
3914
3914
|
// FNV-1a inspired hashing
|
|
3915
3915
|
var hash = (utils.hash = function (str) {
|
|
@@ -3923,12 +3923,12 @@ var hash = (utils.hash = function (str) {
|
|
|
3923
3923
|
});
|
|
3924
3924
|
|
|
3925
3925
|
/**
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3926
|
+
Union arrays
|
|
3927
|
+
@function
|
|
3928
|
+
@param {array} a
|
|
3929
|
+
@param {array} b
|
|
3930
|
+
@return {array}
|
|
3931
|
+
*/
|
|
3932
3932
|
var arrayUnion = (utils.arrayUnion = function (a, b) {
|
|
3933
3933
|
var r = b.slice(0);
|
|
3934
3934
|
a.forEach(function (i) {
|
|
@@ -3940,8 +3940,8 @@ var arrayUnion = (utils.arrayUnion = function (a, b) {
|
|
|
3940
3940
|
});
|
|
3941
3941
|
|
|
3942
3942
|
/**
|
|
3943
|
-
|
|
3944
|
-
|
|
3943
|
+
Array Difference
|
|
3944
|
+
*/
|
|
3945
3945
|
var arrayDiff = (utils.arrayDiff = function (a, b) {
|
|
3946
3946
|
return a.filter(function (i) {
|
|
3947
3947
|
return b.indexOf(i) < 0;
|
|
@@ -3949,8 +3949,8 @@ var arrayDiff = (utils.arrayDiff = function (a, b) {
|
|
|
3949
3949
|
});
|
|
3950
3950
|
|
|
3951
3951
|
/**
|
|
3952
|
-
|
|
3953
|
-
|
|
3952
|
+
Arrays deep intersect (with records)
|
|
3953
|
+
*/
|
|
3954
3954
|
var arrayIntersect = (utils.arrayIntersect = function (a, b) {
|
|
3955
3955
|
var r = [];
|
|
3956
3956
|
a.forEach(function (ai) {
|
|
@@ -3968,8 +3968,8 @@ var arrayIntersect = (utils.arrayIntersect = function (a, b) {
|
|
|
3968
3968
|
});
|
|
3969
3969
|
|
|
3970
3970
|
/**
|
|
3971
|
-
|
|
3972
|
-
|
|
3971
|
+
Arrays deep union (with records)
|
|
3972
|
+
*/
|
|
3973
3973
|
var arrayUnionDeep = (utils.arrayUnionDeep = function (a, b) {
|
|
3974
3974
|
var r = b.slice(0);
|
|
3975
3975
|
a.forEach(function (ai) {
|
|
@@ -3988,8 +3988,8 @@ var arrayUnionDeep = (utils.arrayUnionDeep = function (a, b) {
|
|
|
3988
3988
|
});
|
|
3989
3989
|
|
|
3990
3990
|
/**
|
|
3991
|
-
|
|
3992
|
-
|
|
3991
|
+
Arrays deep union (with records)
|
|
3992
|
+
*/
|
|
3993
3993
|
var arrayExceptDeep = (utils.arrayExceptDeep = function (a, b) {
|
|
3994
3994
|
var r = [];
|
|
3995
3995
|
a.forEach(function (ai) {
|
|
@@ -4008,8 +4008,8 @@ var arrayExceptDeep = (utils.arrayExceptDeep = function (a, b) {
|
|
|
4008
4008
|
});
|
|
4009
4009
|
|
|
4010
4010
|
/**
|
|
4011
|
-
|
|
4012
|
-
|
|
4011
|
+
Arrays deep intersect (with records)
|
|
4012
|
+
*/
|
|
4013
4013
|
var arrayIntersectDeep = (utils.arrayIntersectDeep = function (a, b) {
|
|
4014
4014
|
var r = [];
|
|
4015
4015
|
a.forEach(function (ai) {
|
|
@@ -4028,8 +4028,8 @@ var arrayIntersectDeep = (utils.arrayIntersectDeep = function (a, b) {
|
|
|
4028
4028
|
});
|
|
4029
4029
|
|
|
4030
4030
|
/**
|
|
4031
|
-
|
|
4032
|
-
|
|
4031
|
+
Deep clone objects
|
|
4032
|
+
*/
|
|
4033
4033
|
var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
4034
4034
|
if (null === obj || typeof obj !== 'object') {
|
|
4035
4035
|
return obj;
|
|
@@ -4047,23 +4047,23 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
|
4047
4047
|
return +obj;
|
|
4048
4048
|
}
|
|
4049
4049
|
|
|
4050
|
-
var temp = obj.constructor(); // changed
|
|
4050
|
+
var temp = (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
|
|
4051
4051
|
|
|
4052
4052
|
for (var key in obj) {
|
|
4053
4053
|
if (obj.hasOwnProperty(key)) {
|
|
4054
|
-
temp[key] = cloneDeep(obj[key]);
|
|
4054
|
+
/* 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]); }
|
|
4055
4055
|
}
|
|
4056
4056
|
}
|
|
4057
4057
|
return temp;
|
|
4058
4058
|
});
|
|
4059
4059
|
|
|
4060
4060
|
/**
|
|
4061
|
-
|
|
4062
|
-
|
|
4061
|
+
Check equality of objects
|
|
4062
|
+
*/
|
|
4063
4063
|
|
|
4064
4064
|
/**
|
|
4065
|
-
|
|
4066
|
-
|
|
4065
|
+
Compare two objects in deep
|
|
4066
|
+
*/
|
|
4067
4067
|
var deepEqual = (utils.deepEqual = function (x, y) {
|
|
4068
4068
|
if (x === y) {
|
|
4069
4069
|
return true;
|
|
@@ -4084,10 +4084,10 @@ var deepEqual = (utils.deepEqual = function (x, y) {
|
|
|
4084
4084
|
return false;
|
|
4085
4085
|
});
|
|
4086
4086
|
/**
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4087
|
+
Array with distinct records
|
|
4088
|
+
@param {array} data
|
|
4089
|
+
@return {array}
|
|
4090
|
+
*/
|
|
4091
4091
|
var distinctArray = (utils.distinctArray = function (data) {
|
|
4092
4092
|
var uniq = {};
|
|
4093
4093
|
// TODO: Speedup, because Object.keys is slow
|
|
@@ -4113,17 +4113,17 @@ var distinctArray = (utils.distinctArray = function (data) {
|
|
|
4113
4113
|
});
|
|
4114
4114
|
|
|
4115
4115
|
/**
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4116
|
+
Extend object a with properties of b
|
|
4117
|
+
@function
|
|
4118
|
+
@param {object} a
|
|
4119
|
+
@param {object} b
|
|
4120
|
+
@return {object}
|
|
4121
|
+
*/
|
|
4122
4122
|
var extend = (utils.extend = function extend(a, b) {
|
|
4123
4123
|
a = a || {};
|
|
4124
4124
|
for (var key in b) {
|
|
4125
4125
|
if (b.hasOwnProperty(key)) {
|
|
4126
|
-
a[key] = b[key];
|
|
4126
|
+
/* 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]; }
|
|
4127
4127
|
}
|
|
4128
4128
|
}
|
|
4129
4129
|
return a;
|
|
@@ -4139,8 +4139,8 @@ var getValueOf = (utils.getValueOf = function (val) {
|
|
|
4139
4139
|
});
|
|
4140
4140
|
|
|
4141
4141
|
/**
|
|
4142
|
-
|
|
4143
|
-
|
|
4142
|
+
Flat array by first row
|
|
4143
|
+
*/
|
|
4144
4144
|
var flatArray = (utils.flatArray = function (a) {
|
|
4145
4145
|
|
|
4146
4146
|
if (!a || 0 === a.length) {
|
|
@@ -4164,8 +4164,8 @@ var flatArray = (utils.flatArray = function (a) {
|
|
|
4164
4164
|
});
|
|
4165
4165
|
|
|
4166
4166
|
/**
|
|
4167
|
-
|
|
4168
|
-
|
|
4167
|
+
Convert array of objects to array of arrays
|
|
4168
|
+
*/
|
|
4169
4169
|
var arrayOfArrays = (utils.arrayOfArrays = function (a) {
|
|
4170
4170
|
return a.map(function (aa) {
|
|
4171
4171
|
var ar = [];
|
|
@@ -4183,12 +4183,18 @@ if (!Array.isArray) {
|
|
|
4183
4183
|
}
|
|
4184
4184
|
|
|
4185
4185
|
/**
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4186
|
+
Excel:convert number to Excel column, like 1 => 'A'
|
|
4187
|
+
@param {integer} i Column number, starting with 0
|
|
4188
|
+
@return {string} Column name, starting with 'A'
|
|
4189
|
+
*/
|
|
4190
4190
|
|
|
4191
4191
|
var xlsnc = (utils.xlsnc = function (i) {
|
|
4192
|
+
var first = '';
|
|
4193
|
+
if (i > 701) {
|
|
4194
|
+
let x = (((i - 26) / (26 * 26)) | 0) - 1;
|
|
4195
|
+
first = String.fromCharCode(65 + (x % 26));
|
|
4196
|
+
i = i % (26 * 26);
|
|
4197
|
+
}
|
|
4192
4198
|
var addr = String.fromCharCode(65 + (i % 26));
|
|
4193
4199
|
if (i >= 26) {
|
|
4194
4200
|
i = ((i / 26) | 0) - 1;
|
|
@@ -4198,14 +4204,14 @@ var xlsnc = (utils.xlsnc = function (i) {
|
|
|
4198
4204
|
addr = String.fromCharCode(65 + (i % 26)) + addr;
|
|
4199
4205
|
}
|
|
4200
4206
|
}
|
|
4201
|
-
return addr;
|
|
4207
|
+
return first + addr;
|
|
4202
4208
|
});
|
|
4203
4209
|
|
|
4204
4210
|
/**
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4211
|
+
Excel:conver Excel column name to number
|
|
4212
|
+
@param {string} s Column number, like 'A' or 'BE'
|
|
4213
|
+
@return {string} Column name, starting with 0
|
|
4214
|
+
*/
|
|
4209
4215
|
var xlscn = (utils.xlscn = function (s) {
|
|
4210
4216
|
var n = s.charCodeAt(0) - 65;
|
|
4211
4217
|
if (s.length > 1) {
|
|
@@ -4226,12 +4232,12 @@ var domEmptyChildren = (utils.domEmptyChildren = function (container) {
|
|
|
4226
4232
|
});
|
|
4227
4233
|
|
|
4228
4234
|
/**
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
+
SQL LIKE emulation
|
|
4236
|
+
@parameter {string} pattern Search pattern
|
|
4237
|
+
@parameter {string} value Searched value
|
|
4238
|
+
@parameter {string} escape Escape character (optional)
|
|
4239
|
+
@return {boolean} If value LIKE pattern ESCAPE escape
|
|
4240
|
+
*/
|
|
4235
4241
|
|
|
4236
4242
|
var like = (utils.like = function (pattern, value, escape) {
|
|
4237
4243
|
// Verify escape character
|
|
@@ -4302,9 +4308,9 @@ utils.glob = function (value, pattern) {
|
|
|
4302
4308
|
};
|
|
4303
4309
|
|
|
4304
4310
|
/**
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4311
|
+
Get path of alasql.js
|
|
4312
|
+
@todo Rewrite and simplify the code. Review, is this function is required separately
|
|
4313
|
+
*/
|
|
4308
4314
|
utils.findAlaSQLPath = function () {
|
|
4309
4315
|
/** type {string} Path to alasql library and plugins */
|
|
4310
4316
|
|
|
@@ -8681,7 +8687,7 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8681
8687
|
aft2 = '';
|
|
8682
8688
|
|
|
8683
8689
|
if (typeof query.groupStar !== 'undefined') {
|
|
8684
|
-
aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
|
|
8690
|
+
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];};";
|
|
8685
8691
|
}
|
|
8686
8692
|
|
|
8687
8693
|
/*
|
|
@@ -9003,7 +9009,7 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9003
9009
|
} else {
|
|
9004
9010
|
|
|
9005
9011
|
// if column not exist, then copy all
|
|
9006
|
-
sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
|
|
9012
|
+
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]};';
|
|
9007
9013
|
|
|
9008
9014
|
query.dirtyColumns = true;
|
|
9009
9015
|
}
|
|
@@ -9332,10 +9338,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
|
|
|
9332
9338
|
self.columns.forEach(function (col) {
|
|
9333
9339
|
|
|
9334
9340
|
if (col instanceof yy.Column && col.columnid === '*') {
|
|
9335
|
-
// s += 'for(var k in g){r[k]=g[k]};';
|
|
9341
|
+
// s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9336
9342
|
// s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
|
|
9337
9343
|
|
|
9338
|
-
s += 'for(var k in g) {r[k]=g[k]};';
|
|
9344
|
+
s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9339
9345
|
return '';
|
|
9340
9346
|
|
|
9341
9347
|
} else {
|
|
@@ -12622,7 +12628,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12622
12628
|
|
|
12623
12629
|
table.update(
|
|
12624
12630
|
function (t) {
|
|
12625
|
-
for (var f in r) t[f] = r[f];
|
|
12631
|
+
for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
|
|
12626
12632
|
},
|
|
12627
12633
|
table.data.indexOf(toreplace),
|
|
12628
12634
|
params
|
|
@@ -14196,7 +14202,7 @@ yy.Insert.prototype.compile = function (databaseid) {
|
|
|
14196
14202
|
});
|
|
14197
14203
|
} else {
|
|
14198
14204
|
|
|
14199
|
-
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
|
|
14205
|
+
// 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]};';
|
|
14200
14206
|
sw = JSONtoJS(values);
|
|
14201
14207
|
}
|
|
14202
14208
|
}
|