8000 refactor: Removed dependency on lodash.isArray (#400) · github/optimizely-javascript-sdk@d298f48 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit d298f48

Browse files
authored
refactor: Removed dependency on lodash.isArray (optimizely#400)
Summary: to reduce package size, we are trying to gradually get rid of lodash library. This PR replaces isArray function with Array.isArray. Because lodash is also using this standard built-in objects from javascript. Test plan: All tests pass after this change.
1 parent ab7e371 commit d298f48

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

packages/optimizely-sdk/lib/utils/fns/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = {
2424
currentTimestamp: function() {
2525
return Math.round(new Date().getTime());
2626
},
27-
isArray: require('lodash/isArray'),
2827
isEmpty: require('lodash/isEmpty'),
2928
isFinite: function(number) {
3029
return _isFinite(number) && Math.abs(number) <= MAX_NUMBER_LIMIT;

packages/optimizely-sdk/lib/utils/json_schema_validator/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var fns = require('../fns');
1716
var validate = require('json-schema').validate;
1817
var sprintf = require('@optimizely/js-sdk-utils').sprintf;
1918

@@ -40,7 +39,7 @@ module.exports = {
4039
if (result.valid) {
4140
return true;
4241
} else {
43-
if (fns.isArray(result.errors)) {
42+
if (Array.isArray(result.errors)) {
4443
throw new Error(sprintf(ERROR_MESSAGES.INVALID_DATAFILE, MODULE_NAME, result.errors[0].property, result.errors[0].message));
4544
}
4645
throw new Error(sprintf(ERROR_MESSAGES.INVALID_JSON, MODULE_NAME));

0 commit comments

Comments
 (0)
0