Skip to content

Commit 1d2829f

Browse files
committed
- fix Cache.put
- fix Data.count - stringify data for BrowserRequests - fix isBrowser util method - upgrade Webpack to v3.8.1 - fix build for UMD - optimize UMD build for Web Browser env
1 parent 428a123 commit 1d2829f

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@
6868
"chai": "^3.5.0",
6969
"chai-as-promised": "^6.0.0",
7070
"copyfiles": "^1.1.0",
71-
"cross-env": "^5.0.5",
71+
"cross-env": "^5.1.0",
7272
"eslint": "^3.12.2",
73-
"karma": "^1.3.0",
73+
"karma": "^1.7.1",
7474
"karma-babel-preprocessor": "^6.0.1",
7575
"karma-browserify": "^5.1.0",
7676
"karma-mocha": "^1.3.0",
7777
"karma-phantomjs-launcher": "^1.0.2",
7878
"mocha": "^3.2.0",
79-
"rimraf": "^2.5.4",
80-
"typescript": "^2.0.3",
81-
"uglify-js": "^3.0.15",
79+
"rimraf": "^2.6.2",
80+
"typescript": "^2.5.3",
81+
"uglify-js": "^3.1.4",
8282
"watch": "^1.0.2",
8383
"watchify": "^3.8.0",
84-
"webpack": "^3.5.5"
84+
"webpack": "^3.8.1"
8585
},
8686
"dependencies": {
8787
"backendless-request": "^0.0.9"

src/cache/put.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function put(key, value, timeToLive, asyncHandler) {
1313
timeToLive = undefined
1414
}
1515

16-
if (timeToLive && !Utils.isNumber(key)) {
16+
if (timeToLive && !Utils.isNumber(timeToLive)) {
1717
throw new Error('Cache timeToLive must be Number')
1818
}
1919

src/data/store/count.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function getObjectCount(condition, asyncHandler) {
1111
}
1212

1313
if (condition instanceof DataQueryBuilder) {
14-
condition = condition.build().condition
14+
condition = condition.build().condition || undefined
1515
}
1616

1717
return Request.get({

src/request/request-for-browser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const sendRequest = config => {
5555
} else {
5656
const contentType = config.data ? 'application/json' : 'application/x-www-form-urlencoded'
5757

58+
if (contentType === 'application/json' && config.data && typeof config.data !== 'string') {
59+
config.data = JSON.stringify(config.data)
60+
}
61+
5862
xhr.setRequestHeader('Content-Type', contentType)
5963
}
6064

src/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Utils = {
2929
return Object.prototype.toString.call(obj).slice(8, -1) === 'Date'
3030
},
3131

32-
isBrowser: (new Function('try {return this===window;}catch(e){ return false;}'))(),
32+
isBrowser: isBrowser(),
3333

3434
castArray(value) {
3535
if (Utils.isArray(value)) {
@@ -184,6 +184,10 @@ const Utils = {
184184
}
185185
}
186186

187+
function isBrowser(){
188+
return (typeof self === 'object' && self.self === self) && (typeof window === 'object' && window === self)
189+
}
190+
187191
function classWrapper(obj) {
188192
//TODO: refactor it
189193
const wrapper = obj => {

webpack.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ const uglify = new webpack.optimize.UglifyJsPlugin({
2323

2424
module.exports = {
2525
devtool: 'source-map',
26-
target : 'node',
26+
27+
target : 'web',
28+
29+
node: {
30+
Buffer: false
31+
},
2732

2833
module: {
34+
noParse: /backendless-request/,
35+
2936
rules: [
3037
{
3138
test : /\.js$/,

0 commit comments

Comments
 (0)