Skip to content

Commit 9a1d2f4

Browse files
committed
Merge branch 'release/0.3.9'
2 parents ef5d15e + e6434a5 commit 9a1d2f4

21 files changed

+15165
-14620
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ branches:
77
language: node_js
88
node_js:
99
- "node"
10+
- "6"
1011
- "5"
1112
- "4"
1213
- "0.12"

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Changelog
22

33

4-
_0.3.9 "Turua" (xx.04.2017)_
4+
_0.3.10 "???" (xx.04.2017)_
55

6-
* ...
6+
* ...
7+
8+
### 0.3.9 "Turua" (23.03.2017)
9+
* Add: React native support
10+
* Fix: CSV error when quote set to empty
11+
* Fix: autoExt bug when not set for CSV on read
712

8-
###0.3.8 "Wanaka" (15.03.2017)
13+
### 0.3.8 "Wanaka" (15.03.2017)
914

1015
* Added: Lazy promise notation
1116
* Added: Create user defined function via SQL statement

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Thank you very much or the your intentions! AlaSQL project still has a lot of th
44

55
For you to edit the source please do the following:
66

7-
- Fork the repo here on Github
8-
- Clone your forked repo and install dependencies `git clone https://github.com/MYUSERNAME/alasql/ && cd alasql && npm install`
7+
- Fork the repo here on Github
8+
- Clone your forked repo and install dependencies `git clone https://github.com/MYUSERNAME/alasql/ --depth 1 && cd alasql && npm install`
99
- Make sure you work with the develop branch `git checkout develop`
1010
- Add a test for the issue: Copy `test/test000.js` and replace `000` with a new number.
1111
- Implement a test that reflects the issue.

LICENSE

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2014-2015 Andrey Gershun ([email protected]) &
4-
Mathias Rangel Wulff ([email protected])
3+
Copyright (c) 2017 Andrey Gershun
54

65
Permission is hereby granted, free of charge, to any person obtaining a copy
76
of this software and associated documentation files (the "Software"), to deal
@@ -20,9 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2019
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2120
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2221
SOFTWARE.
23-
24-
------------------------------------------------------------------------------
25-
26-
The MIT license on this repo covers all contents of the repo, but does not
27-
supercede the existing licenses for products used for this work, including the
28-
Chinook Database (covered by the Microsoft Public License) and other products.

README.md

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

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@
5858
"bin",
5959
"lib"
6060
],
61-
"version": "0.3.8"
61+
"version": "0.3.9"
6262
}

dist/alasql-worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.3.8 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.3.9 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.3.8
4+
@version 0.3.9
55
66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff

dist/alasql-worker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/alasql.fs.js

100644100755
Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.3.8 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.3.9 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.3.8
4+
@version 0.3.9
55

66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -137,7 +137,7 @@ var alasql = function(sql, params, cb, scope) {
137137
Current version of alasql
138138
@constant {string}
139139
*/
140-
alasql.version = '0.3.8';
140+
alasql.version = '0.3.9';
141141

142142
/**
143143
Debug flag
@@ -3391,7 +3391,7 @@ utils.isMeteor = (function(){
33913391
Find out if code is running on a Meteor client
33923392
@return {boolean} True if code is running on a Meteor client
33933393
*/
3394-
utils.isMeteorClient = (utils.isMeteorClient = function(){
3394+
utils.isMeteorClient = utils.isMeteorClient = (function(){
33953395
return utils.isMeteor && Meteor.isClient;
33963396
})();
33973397

@@ -3413,6 +3413,18 @@ utils.isCordova = (function(){
34133413
return (typeof cordova === 'object')
34143414
})();
34153415

3416+
utils.isReactNative = (function(){
3417+
var isReact = false;
3418+
//*not-for-browser/*
3419+
try{
3420+
if(typeof require('react-native') === 'object'){
3421+
isReact = true;
3422+
}
3423+
}catch(e){void 0 }
3424+
//*/
3425+
return isReact;
3426+
})();
3427+
34163428
utils.hasIndexedDB = (function(){
34173429
return !!utils.global.indexedDB;
34183430
})();
@@ -3479,7 +3491,15 @@ var loadFile = utils.loadFile = function(path, asy, success, error) {
34793491
}
34803492
}
34813493
}
3482-
//*/
3494+
} else if(utils.isReactNative) {
3495+
// If ReactNative
3496+
var RNFS = require('react-native-fs');
3497+
RNFS.readFile(path,'utf8').then(function(contents){
3498+
success(cutbom(contents));
3499+
}).catch(function(err){
3500+
throw err;
3501+
});
3502+
//*/
34833503
} else if(utils.isCordova) {
34843504
/* If Cordova */
34853505
utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
@@ -3609,9 +3629,18 @@ var loadBinaryFile = utils.loadBinaryFile = function(path, asy, success, error)
36093629
success(arr.join(""));
36103630
}
36113631
}
3612-
//*/
3632+
} else if(utils.isReactNative) {
3633+
// If ReactNative
3634+
//var RNFS = require('react-native-fs');
3635+
var RNFetchBlob = require('react-native-fetch-blob').default
3636+
var dirs = RNFetchBlob.fs.dirs
3637+
//should use readStream instead if the file is large
3638+
RNFetchBlob.fs.readFile(path, 'base64').then(function(data){
3639+
//RNFetchBlob.base64.decode(data) //need more test on excel
3640+
success(data);
3641+
})
3642+
//*/
36133643
} else {
3614-
36153644
if(typeof path === "string") {
36163645
// For browser
36173646
var xhr = new XMLHttpRequest();
@@ -3657,7 +3686,15 @@ var removeFile = utils.removeFile = function(path,cb) {
36573686
cb && cb(); // jshint ignore:line
36583687
});
36593688
});
3660-
//*/
3689+
} else if(utils.isReactNative) {
3690+
// If ReactNative
3691+
var RNFS = require('react-native-fs');
3692+
RNFS.unlink(path).then(function(){
3693+
cb && cb();
3694+
}).catch(function(err){
3695+
throw err;
3696+
});
3697+
//*/
36613698
} else {
36623699
throw new Error('You can remove files only in Node.js and Apache Cordova');
36633700
}
@@ -3669,13 +3706,22 @@ var deleteFile = utils.deleteFile = function(path,cb){
36693706
if(utils.isNode) {
36703707
var fs = require('fs');
36713708
fs.unlink(path, cb);
3709+
} else if(utils.isReactNative) {
3710+
// If ReactNative
3711+
var RNFS = require('react-native-fs');
3712+
RNFS.unlink(path).then(function(){
3713+
cb && cb();
3714+
}).catch(function(err){
3715+
throw err;
3716+
});
36723717
}
36733718
//*/
36743719

36753720
};
36763721

36773722
utils.autoExtFilename = function(filename,ext,config) {
3678-
if(typeof filename !== 'string' || filename.match(/\..{2,4}$/) || config.autoExt === 0 || config.autoExt === false){
3723+
config = config || {};
3724+
if(typeof filename !== 'string' || filename.match(/^[A-z]+:\/\/|\n|\..{2,4}$/) || config.autoExt === 0 || config.autoExt === false){
36793725
return filename;
36803726
}
36813727
return filename+'.'+ext
@@ -3694,7 +3740,15 @@ var fileExists = utils.fileExists = function(path,cb){
36943740
cb(false);
36953741
});
36963742
});
3697-
//*/
3743+
} else if(utils.isReactNative) {
3744+
// If ReactNative
3745+
var RNFS = require('react-native-fs');
3746+
RNFS.exists(path).then(function(yes){
3747+
cb && cb(yes);
3748+
}).catch(function(err){
3749+
throw err;
3750+
});
3751+
//*/
36983752
} else {
36993753
// TODO Cordova, etc.
37003754
throw new Error('You can use exists() only in Node.js or Apach Cordova');
@@ -3721,14 +3775,20 @@ var saveFile = utils.saveFile = function(path, data, cb, opts) {
37213775
res = cb(res);
37223776
}
37233777
} else {
3724-
37253778
if(utils.isNode) {
37263779
//*not-for-browser/*
37273780
var fs = require('fs');
37283781
data = fs.writeFileSync(path,data);
37293782
if(cb){
37303783
res = cb(res);
37313784
}
3785+
}else if(utils.isReactNative) {
3786+
var RNFS = require('react-native-fs');
3787+
RNFS.writeFile(path, data).then(function(success){ //, 'utf8'
3788+
if(cb) res = cb(res);
3789+
}).catch(function(err){
3790+
console.log(err.message);
3791+
});
37323792
} else if(utils.isCordova) {
37333793
utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
37343794

@@ -14454,7 +14514,10 @@ alasql.into.CSV = function(filename, opts, data, columns, cb) {
1445414514
data.forEach(function(d){
1445514515
s += columns.map(function(col){
1445614516
var s = d[col.columnid];
14457-
s = (s+"").replace(new RegExp('\\'+opt.quote,"g"),'""');
14517+
// escape the character wherever it appears in the field
14518+
if (opt.quote !== '') {
14519+
s = (s+"").replace(new RegExp('\\'+opt.quote,"g"), opt.quote + opt.quote);
14520+
}
1445814521

1445914522
//Excel 2013 needs quotes around strings - thanks for _not_ complying with RFC for CSV
1446014523
if(+s!=s){ // jshint ignore:line

0 commit comments

Comments
 (0)