TypeScript conversion (#142)
* Auto-conversion * Cleanup type conversion errors * Inching closer, resolution sorted * Additional cleanups * TS, TS everywhere * Minor version for TS release * Last roundups
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
// Copyright 2017-2018 @polkadot/util authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
import isNull from '../is/null';
|
||||
import isUndefined from '../is/undefined';
|
||||
|
||||
/**
|
||||
@name arrayFilter
|
||||
@signature arrayFilter (array: Array<mixed>, allowNulls: boolean = true): Array<mixed>
|
||||
@signature arrayFilter (array: Array<any>, allowNulls: boolean = true): Array<any>
|
||||
@summary Filters undefined and (optionally) null values from an array
|
||||
@description
|
||||
Returns a new array with all `undefined` values removed. Optionally, when `allowNulls = false`, it removes the `null` values as well
|
||||
@@ -18,7 +17,7 @@ import isUndefined from '../is/undefined';
|
||||
arrayFilter([0, void 0, true, null, false, '']); // [0, true, null, false, '']
|
||||
arrayFilter([0, void 0, true, null, false, ''], false); // [0, true, false, '']
|
||||
*/
|
||||
export default function arrayFilter (array: Array<mixed>, allowNulls: boolean = true): Array<mixed> {
|
||||
export default function arrayFilter (array: Array<any>, allowNulls: boolean = true): Array<any> {
|
||||
return array.filter((value) => {
|
||||
return !isUndefined(value) && (allowNulls || !isNull(value));
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2017-2018 @polkadot/util authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
import arrayFilter from './filter';
|
||||
|
||||
Reference in New Issue
Block a user