Skip to content

Commit b06b0a6

Browse files
committed
fix: prevent to use _(list).each
This fix a wired issue w/ taro and minified bundle.
1 parent c1d5a08 commit b06b0a6

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/localstorage.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
var _ = require('underscore');
21
var Promise = require('./promise');
32
var localStorage = require('./utils/localstorage');
43

54
var syncApiNames = ['getItem', 'setItem', 'removeItem', 'clear'];
65

76
if (!localStorage.async) {
87
// wrap sync apis with async ones.
9-
_(syncApiNames).each(function(apiName) {
8+
syncApiNames.forEach(function(apiName) {
109
if (typeof localStorage[apiName] === 'function') {
1110
localStorage[apiName + 'Async'] = function() {
1211
return Promise.resolve(
@@ -16,7 +15,7 @@ if (!localStorage.async) {
1615
}
1716
});
1817
} else {
19-
_(syncApiNames).each(function(apiName) {
18+
syncApiNames.forEach(function(apiName) {
2019
if (typeof localStorage[apiName] !== 'function') {
2120
localStorage[apiName] = function() {
2221
const error = new Error(

src/query.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ module.exports = function(AV) {
966966
*/
967967
include: function(keys) {
968968
requires(keys, 'undefined is not a valid key');
969-
_(arguments).forEach(keys => {
969+
_.forEach(arguments, keys => {
970970
this._include = this._include.concat(ensureArray(keys));
971971
});
972972
return this;
@@ -991,7 +991,7 @@ module.exports = function(AV) {
991991
*/
992992
select: function(keys) {
993993
requires(keys, 'undefined is not a valid key');
994-
_(arguments).forEach(keys => {
994+
_.forEach(arguments, keys => {
995995
this._select = this._select.concat(ensureArray(keys));
996996
});
997997
return this;

src/utils/localstorage-browser.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var _ = require('underscore');
2-
31
// interface Storage {
42
// readonly attribute boolean async;
53
// string getItem(string key);
@@ -28,7 +26,7 @@ try {
2826
}
2927

3028
// in browser, `localStorage.async = false` will excute `localStorage.setItem('async', false)`
31-
_(apiNames).each(function(apiName) {
29+
apiNames.forEach(function(apiName) {
3230
Storage[apiName] = function() {
3331
return localStorage[apiName].apply(localStorage, arguments);
3432
};

0 commit comments

Comments
 (0)