Skip to content

Commit

Permalink
chore: Fix links
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidmt committed Oct 12, 2020
1 parent 2f76c17 commit 568fb2e
Showing 1 changed file with 56 additions and 46 deletions.
102 changes: 56 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- markdownlint-disable first-line-h1 line-length -->

[![CircleCI](https://circleci.com/gh/andreidmt/m.xyz.svg?style=svg)](https://circleci.com/gh/andreidmt/m.xyz)
[![npm version](https://badge.fury.io/js/m.xyz.svg)](https://www.npmjs.com/package/m.xyz)
[![dev-badge](https://david-dm.org/andreidmt/m.xyz.svg)](https://david-dm.org/andreidmt/m.xyz)
[![Coverage Status](https://coveralls.io/repos/github/andreidmt/m.xyz/badge.svg)](https://coveralls.io/github/andreidmt/m.xyz)
[![CircleCI](https://circleci.com/gh/asd14-xyz/m.svg?style=svg)](https://circleci.com/gh/asd14-xyz/m)
[![npm version](https://badge.fury.io/js/%40asd14%2Fm.svg)](https://badge.fury.io/js/%40asd14%2Fm)
[![dev-badge](https://david-dm.org/asd14-xyz/m.svg)](https://david-dm.org/asd14-xyz/m)
[![Coverage Status](https://coveralls.io/repos/github/asd14-xyz/m/badge.svg)](https://coveralls.io/github/asd14-xyz/m)

# m

Expand All @@ -15,21 +15,44 @@ Experimental. Use [Ramda](https://github.com/ramda/ramda).

<!-- vim-markdown-toc GFM -->

* [Install](#install)
* [Use](#use)
* ["With" pattern](#with-pattern)
* [|> pipe](#-pipe)
* [Install](#install)
* [Develop](#develop)
* [Use](#use)
* [Changelog](#changelog)

<!-- vim-markdown-toc -->

## Install

```bash
npm install @asd14/m
```

## Use

```js
import { pipe, trim, split, dropLast, push, join } from "@asd14/m"

const removeTrailingSlash = source =>
source[source.length - 1] === sep ? source.slice(0, -1) : source

const renameFile = newName => pipe(
removeTrailingSlash,
split(sep),
dropLast,
push(trim(sep, newName)),
join(sep)
)
```

## "With" pattern

Most array 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.
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.

```js
import { find, findWith, filterWith, not, is } from "m.xyz"
import { find, findWith, filterWith, not, is } from "@asd14/m"

const todos = [
{id: 1, name: "lorem", tagId: 2,},
Expand All @@ -41,26 +64,36 @@ const todos = [
```js
/* Predicate fn */
find(
item => item.id === 1
)(todos)
item => item.id === 1,
todos
)
// => {id: 1, name: "lorem", tagId: 2}

/* Matching object */
findWith({
"id": 1
})(todos)
findWith(
{
"id": 1
},
todos
)
// => {id: 1, name: "lorem", tagId: 2}

/* Matching object & predicate fn */
filterWith({
"tagId": is // same as `tagId: source => is(source)`
})(todos)
filterWith(
{
"tagId": is // same as `tagId: source => is(source)`
},
todos
)
// => [{id: 1, name: "lorem", tagId: 2}]

/* Syntactic sugar */
filterWith({
"!tagId": is // same as `tagId: not(is)`
})(todos)
filterWith(
{
"!tagId": is // same as `tagId: not(is)`
},
todos
)
// => [
// {id: 2, name: "ipsum", tagId: null},
// {id: 3, name: "dolor", tagId: null}
Expand All @@ -79,11 +112,11 @@ Given that:
* [left/back is in the past, right/front is the future](https://medium.com/@cwodtke/the-intuitive-and-the-unlearnable-cccffd9a762)
* a lot of piping going on in your terminal

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`. The way is forward :godmode:.
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`.

```js
const { sep } = require("path")
const { pipe, compose, join, push, dropLast, split } = require("m.xyz")
const { pipe, compose, join, push, dropLast, split } = require("@asd14/m")

// Compose: g(f(x))
const renameFile = newName => filePath =>
Expand All @@ -102,16 +135,10 @@ const renameFile = newName => filePath =>
filePath |> split(sep) |> dropLast |> push(newName) |> join(sep)
```

## Install

```bash
npm install m.xyz
```

## Develop

```bash
git clone [email protected]:andreidmt/m.xyz.git && \
git clone [email protected]:asd14-xyz/m.git && \
cd m && \
npm run setup

Expand All @@ -122,23 +149,6 @@ npm test
npm run tdd
```

## Use

```js
import { pipe, trim, split, dropLast, push, join } from "m.xyz"

const removeTrailingSlash = source =>
source[source.length - 1] === sep ? source.slice(0, -1) : source

const renameFile = newName => pipe(
removeTrailingSlash,
split(sep),
dropLast,
push(trim(sep)(newName)),
join(sep)
)
```

## Changelog

See the [releases section](https://github.com/andreidmt/m.xyz/releases) for details.
See the [releases section](https://github.com/asd14-xyz/m/releases) for details.

0 comments on commit 568fb2e

Please sign in to comment.