Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
61b113930c | |||
9bd675692d |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartarray",
|
"name": "@pushrocks/smartarray",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartarray",
|
"name": "@pushrocks/smartarray",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartarray",
|
"name": "@pushrocks/smartarray",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a package exposing async manipulation for arrays",
|
"description": "a package exposing async manipulation for arrays",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
10
test/test.ts
10
test/test.ts
@ -1,8 +1,14 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartarray from '../ts/index';
|
import * as smartarray from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('should filter', async () => {
|
||||||
console.log(smartarray.standardExport);
|
const originalArray = [1,2,3,4,5,6];
|
||||||
|
expect(originalArray).to.contain(2);
|
||||||
|
expect(originalArray).to.contain(3);
|
||||||
|
const result = await smartarray.filter(originalArray, async itemArg => itemArg !== 3);
|
||||||
|
expect(originalArray).to.contain(2);
|
||||||
|
expect(result).to.not.contain(3);
|
||||||
|
console.log(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
13
ts/index.ts
13
ts/index.ts
@ -1,3 +1,10 @@
|
|||||||
import * as plugins from './smartarray.plugins';
|
export const filter = async<T>(arrayArg: T[], filterFunction: (itemArg: T) => Promise<boolean>): Promise<T[]> => {
|
||||||
|
const returnArray: T[] = [];
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
for (const itemArg of arrayArg) {
|
||||||
|
const filterResult = await filterFunction(itemArg);
|
||||||
|
if (filterResult) {
|
||||||
|
returnArray.push(itemArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnArray;
|
||||||
|
}
|
Reference in New Issue
Block a user