@@ -3,8 +3,8 @@
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
const isNull = require('../is/null');
|
||||
const isUndefined = require('../is/undefined');
|
||||
import isNull from '../is/null';
|
||||
import isUndefined from '../is/undefined';
|
||||
|
||||
/**
|
||||
@name arrayFilter
|
||||
@@ -18,8 +18,8 @@ const isUndefined = require('../is/undefined');
|
||||
arrayFilter([0, void 0, true, null, false, '']); // [0, true, null, false, '']
|
||||
arrayFilter([0, void 0, true, null, false, ''], false); // [0, true, false, '']
|
||||
*/
|
||||
module.exports = function arrayFilter (array: Array<mixed>, allowNulls: boolean = true): Array<mixed> {
|
||||
export default function arrayFilter (array: Array<mixed>, allowNulls: boolean = true): Array<mixed> {
|
||||
return array.filter((value) => {
|
||||
return !isUndefined(value) && (allowNulls || !isNull(value));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
const { arrayFilter } = require('./index');
|
||||
import { arrayFilter } from './index';
|
||||
|
||||
describe('filterArray', () => {
|
||||
it('filters arrays, removing undefined', () => {
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
const arrayFilter = require('./filter');
|
||||
import arrayFilter from './filter';
|
||||
|
||||
/**
|
||||
@summary Utility methods that operates on arrays
|
||||
*/
|
||||
module.exports = {
|
||||
export {
|
||||
arrayFilter
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user