mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-08-11 11:40:22 +00:00
integrate with underscroe.js
This commit is contained in:
+2
-1
@@ -82,7 +82,8 @@
|
||||
"classnames": "2.2.5",
|
||||
"prop-types": "15.5.10",
|
||||
"react": "16.3.2",
|
||||
"react-dom": "16.3.2"
|
||||
"react-dom": "16.3.2",
|
||||
"underscore": "1.9.1"
|
||||
},
|
||||
"jest": {
|
||||
"collectCoverageFrom": [
|
||||
|
||||
+3
-25
@@ -1,6 +1,7 @@
|
||||
/* eslint no-empty: 0 */
|
||||
/* eslint no-param-reassign: 0 */
|
||||
/* eslint prefer-rest-params: 0 */
|
||||
import _ from 'underscore';
|
||||
|
||||
function splitNested(str) {
|
||||
return [str]
|
||||
@@ -38,22 +39,8 @@ function set(target, field, value, safe = false) {
|
||||
}, target);
|
||||
}
|
||||
|
||||
function isFunction(obj) {
|
||||
return obj && (typeof obj === 'function');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is the Object. the `Object` except `Function` and `Array.`
|
||||
*
|
||||
* @param {*} obj - The value gonna check
|
||||
*/
|
||||
function isObject(obj) {
|
||||
const type = typeof obj;
|
||||
return obj !== null && type === 'object' && obj.constructor === Object;
|
||||
}
|
||||
|
||||
function isEmptyObject(obj) {
|
||||
if (!isObject(obj)) return false;
|
||||
if (!_.isObject(obj)) return false;
|
||||
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const keys = Object.keys(obj);
|
||||
@@ -96,13 +83,4 @@ function debounce(func, wait, immediate) {
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
get,
|
||||
set,
|
||||
isFunction,
|
||||
isObject,
|
||||
isEmptyObject,
|
||||
isDefined,
|
||||
sleep,
|
||||
debounce
|
||||
};
|
||||
export default Object.assign(_, { get, set, isDefined, isEmptyObject, sleep, debounce });
|
||||
|
||||
@@ -58,32 +58,6 @@ describe('Utils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isObject', () => {
|
||||
describe('when given Object', () => {
|
||||
it('should return true', () => {
|
||||
expect(_.isObject({})).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given Function', () => {
|
||||
it('should return false', () => {
|
||||
expect(_.isObject(() => 'test')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given Array', () => {
|
||||
it('should return false', () => {
|
||||
expect(_.isObject([])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given null', () => {
|
||||
it('should return false', () => {
|
||||
expect(_.isObject(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isEmptyObject', () => {
|
||||
describe('when given empty Object', () => {
|
||||
it('should return true', () => {
|
||||
@@ -98,14 +72,14 @@ describe('Utils', () => {
|
||||
});
|
||||
|
||||
describe('when given Function', () => {
|
||||
it('should return false', () => {
|
||||
expect(_.isEmptyObject(() => 'test')).toBe(false);
|
||||
it('should return true', () => {
|
||||
expect(_.isEmptyObject(() => 'test')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given Array', () => {
|
||||
it('should return false', () => {
|
||||
expect(_.isEmptyObject([])).toBe(false);
|
||||
it('should return true', () => {
|
||||
expect(_.isEmptyObject([])).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -8286,6 +8286,10 @@ unc-path-regex@^0.1.2:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa"
|
||||
|
||||
underscore@1.9.1:
|
||||
version "1.9.1"
|
||||
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961"
|
||||
|
||||
underscore@~1.4.4:
|
||||
version "1.4.4"
|
||||
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.4.4.tgz#61a6a32010622afa07963bf325203cf12239d604"
|
||||
|
||||
Reference in New Issue
Block a user