Gathering detailed insights and metrics for @asd14/m
Gathering detailed insights and metrics for @asd14/m
Gathering detailed insights and metrics for @asd14/m
Gathering detailed insights and metrics for @asd14/m
npm install @asd14/m
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4 Stars
548 Commits
1 Forks
4 Watching
7 Branches
3 Contributors
Updated on 30 Jan 2022
JavaScript (99.6%)
Shell (0.4%)
Cumulative downloads
Total Downloads
Last day
-83.7%
8
Compared to previous day
Last week
-18.2%
45
Compared to previous week
Last month
81.4%
176
Compared to previous month
Last year
-67.3%
2,675
Compared to previous year
3
26
Point free style, functional library for Javascript with focus on object arrays.
1npm install @asd14/m
1import { pipe, trim, split, dropLast, push, join } from "@asd14/m" 2 3const removeTrailingSlash = source => 4 source[source.length - 1] === sep ? source.slice(0, -1) : source 5 6const renameFile = newName => 7 pipe( 8 removeTrailingSlash, 9 split(sep), 10 dropLast, 11 push(trim(sep, newName)), 12 join(sep) 13 )
Some functions have a *With
variant. find
has findWith
, filter
has
filterWith
etc. They allow for less boilerplate and more intuitive way of
handling object arrays.
1import { find, findWith, filterWith, not, is } from "@asd14/m" 2 3const todos = [ 4 { id: 1, name: "lorem", tagId: 2 }, 5 { id: 2, name: "ipsum", tagId: null }, 6 { id: 3, name: "dolor", tagId: null }, 7]
1/* Predicate fn */ 2find(item => item.id === 1, todos) 3// => {id: 1, name: "lorem", tagId: 2} 4 5/* Matching object */ 6findWith( 7 { 8 id: 1, 9 }, 10 todos 11) 12// => {id: 1, name: "lorem", tagId: 2} 13 14/* Matching object & predicate fn */ 15filterWith( 16 { 17 tagId: is, // same as `tagId: source => is(source)` 18 }, 19 todos 20) 21// => [{id: 1, name: "lorem", tagId: 2}] 22 23/* Syntactic sugar */ 24filterWith( 25 { 26 "!tagId": is, // same as `tagId: not(is)` 27 }, 28 todos 29) 30// => [ 31// {id: 2, name: "ipsum", tagId: null}, 32// {id: 3, name: "dolor", tagId: null} 33// ]
There is no structure difference between pipe
and compose
, both will use
the same building blocks to get from A to B.
A series of transformations over an initial input can be written as
x -> f -> g -> result
, piping, or as result = g(f(x))
, composing. The
difference is only syntactic. Input is the same, transformations and order
of application are the same, the result will be the same.
Given that:
it makes sense to choose the syntax more aligned with our intuition and
context. The transformations are applied in a certain order with time as a
medium - input -> t0 -> t1 -> tn -> output
.
1const { sep } = require("path") 2const { pipe, compose, join, push, dropLast, split } = require("@asd14/m") 3 4// Compose: g(f(x)) 5const renameFile = newName => filePath => 6 compose(join(sep), push(newName), dropLast, split(sep))(filePath) 7 8// Pipe: x -> f -> g 9const renameFile = newName => filePath => 10 pipe(split(sep), dropLast, push(newName), join(sep))(filePath) 11 12// More expressive with pipeline operator 13const renameFile = newName => filePath => 14 filePath |> split(sep) |> dropLast |> push(newName) |> join(sep)
1git clone git@github.com:asd14-xyz/m.git && \ 2 cd m && \ 3 npm run setup 4 5# run tests (any `*.test.js`) once 6npm test 7 8# watch `src` folder for changes and run test automatically 9npm run tdd
Thank you for contributing your time and knowledge:
See the releases section for details.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
19 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More