Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHart committed Jun 17, 2020
0 parents commit fc1e82b
Show file tree
Hide file tree
Showing 11 changed files with 2,926 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": ["@babel/preset-env"],
"plugins": ["@babel/transform-flow-strip-types"],
"ignore": ["**/*.test.js"]
}
11 changes: 11 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[ignore]

[include]

[libs]

[lints]

[options]

[strict]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Flow Filter Nulls

A little util for filtering nulls from an array in a typesafe way using flow.

This exists mostly for me to learn about setting up and deploying library packages on npm.
12 changes: 12 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = filterNulls;

function filterNulls(array) {
return array.filter(function (item) {
return item != null;
}).filter(Boolean);
}
5 changes: 5 additions & 0 deletions lib/index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow strict

export default function filterNulls<T>(array: Array<?T>): Array<T> {
return array.filter((item) => item != null).filter(Boolean);
}
Empty file added lib/index.test.js.flow
Empty file.
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "flow-filter-null",
"version": "1.0.0",
"description": "Flow typed filtering of nulls from arrays",
"main": "lib/index.js",
"author": "Joe Hart <[email protected]>",
"license": "MIT",
"scripts": {
"prepack": "npm run prepack:babel && npm run prepack:flow",
"prepack:babel": "babel src/ -d lib",
"prepack:flow": "flow-copy-source src lib"
},
"files": [
"lib"
],
"devDependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/plugin-transform-flow-strip-types": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"babel-preset-es2015": "^6.24.1",
"flow-bin": "^0.127.0",
"flow-copy-source": "^2.0.9"
}
}
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow strict

export default function filterNulls<T>(array: Array<?T>): Array<T> {
return array.filter((item) => item != null).filter(Boolean);
}
Empty file added src/index.test.js
Empty file.
2,857 changes: 2,857 additions & 0 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit fc1e82b

Please sign in to comment.