{"id":21730509,"url":"https://github.com/andy2046/lowdash","last_synced_at":"2025-03-20T23:24:02.368Z","repository":{"id":143814952,"uuid":"110190547","full_name":"andy2046/lowdash","owner":"andy2046","description":"lowdash","archived":false,"fork":false,"pushed_at":"2018-02-25T15:11:16.000Z","size":87,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-12T21:46:37.843Z","etag":null,"topics":["compose","curry","functor","javascript","monad","pipe","transduce"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andy2046.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-10T02:09:22.000Z","updated_at":"2023-10-18T14:59:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"cde7e709-24c4-4368-bf15-902498e7ec43","html_url":"https://github.com/andy2046/lowdash","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Flowdash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Flowdash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Flowdash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Flowdash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andy2046","download_url":"https://codeload.github.com/andy2046/lowdash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244707519,"owners_count":20496748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compose","curry","functor","javascript","monad","pipe","transduce"],"created_at":"2024-11-26T04:16:12.250Z","updated_at":"2025-03-20T23:24:02.347Z","avatar_url":"https://github.com/andy2046.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lowdash\nlowdash is a functional JavaScript library including **compose**, **pipe**, **curry**, **transduce**, **identity**, **trace**, **Functor**, **Monad**, **Applicative**\n\n## Examples\n```js\nconst {compose, curry, pipe, identity, trace, transduce, Functor, Monad, Applicative} = require('lowdash')\n\n// curry\n\nconst match = curry(function(what, str) {\n  return str.match(what)\n})\n\nconst replace = curry(function(what, replacement, str) {\n  return str.replace(what, replacement)\n})\n\nconst filter = curry(function(f, ary) {\n  return ary.filter(f)\n})\n\nconst map = curry(function(f, ary) {\n  return ary.map(f)\n})\n\nmatch(/\\s+/g)('hello world')\n//=\u003e [ ' ' ]\n\nconst hasSpaces = match(/\\s+/g)\n// function(x) { return x.match(/\\s+/g) }\n\nhasSpaces('hello world')\n//=\u003e [ ' ' ]\n\nhasSpaces('spaceless')\n//=\u003e null\n\nfilter(hasSpaces, ['the_spelling', 'te amo'])\n//=\u003e ['te amo']\n\nconst findSpaces = filter(hasSpaces)\n// function(xs) { return xs.filter(function(x) { return x.match(/\\s+/g) }) }\n\nfindSpaces(['the_spelling', 'te amo'])\n//=\u003e ['te amo']\n\nconst noVowels = replace(/[aeiou]/ig)\n// function(replacement, x) { return x.replace(/[aeiou]/ig, replacement) }\n\nconst censored = noVowels('*')\n// function(x) { return x.replace(/[aeiou]/ig, '*') }\n\ncensored('Chocolate Cake')\n//=\u003e 'Ch*c*l*t* C*k*'\n\n// compose\n\nconst toUpperCase = function(x) { return x.toUpperCase() }\nconst exclaim = function(x) { return x + '!' }\nconst shout = compose(exclaim, toUpperCase)\n\nshout('angry or hungry')\n//=\u003e 'ANGRY OR HUNGRY!'\n\nconst reduce = curry(function(f, ary) {\n  return ary.reduce(f)\n})\n\nconst head = function(x) { return x[0] }\nconst reverse = reduce(function(acc, x) { return [x].concat(acc) })\nconst last = compose(head, reverse)\n\nlast(['jump', 'house', 'upper'])\n//=\u003e 'upper'\n\nconst lastUpper = compose(toUpperCase, head, reverse)\n\nlastUpper(['jump', 'house', 'upper'])\n//=\u003e 'UPPER'\n\n// pipe\n\nconst shoutPipe = pipe(exclaim, toUpperCase)\n\nconsole.log( shoutPipe('angry or hungry') )\n//=\u003e 'ANGRY OR HUNGRY!'\n\n// pointfree\n\nconst toLowerCase = function(x) { return x.toLowerCase() }\nconst snakeCase = compose(replace(/\\s+/ig, '_'), toLowerCase)\n\nsnakeCase('Snake Case')\n//=\u003e 'snake_case'\n\nconst split = curry(function(separator, str) {\n  return str.split(separator)\n})\nconst join = curry(function(separator, ary) {\n  return ary.join(separator)\n})\nconst initials = compose(join('. '), map(compose(toUpperCase, head)), split(' '))\n\ninitials('json jackson jason')\n//=\u003e 'J. J. J'\n\n// transduce =  transform + reduce\n\nconst t = curry(transduce)(\n  compose(map(x =\u003e x +1), filter(x =\u003e x \u003e 2)),\n  (result, x) =\u003e result.concat(x),\n  []\n)\nconsole.log(t([1,2,3,4]))\n//=\u003e [4, 5]\n\n// debug\n\nconst dasherize = compose(join('-'), map(toLowerCase), trace('after split'),\n  split(' '), replace(/\\s{2,}/ig, ' '))\n\ndasherize('The world is a  vampire')\n//=\u003e after split [ 'The', 'world', 'is', 'a', 'vampire' ]\n//=\u003e 'the-world-is-a-vampire'\n\n// Functor, Monad, Applicative\n\nconst increment = x =\u003e x + 1\nconst add2 = compose(increment, increment)\nconst add4 = compose(add2, add2)\n\nconsole.log(\n  Functor.of(1)\n    .map(increment)\n    .map(add4)\n)\n\nconst incrementMonad = compose(Monad.of, increment)\nconst add2Monad = x =\u003e Monad.of(x).bind(incrementMonad).bind(incrementMonad)\nconst add4Monad = x =\u003e Monad.of(x).bind(add2Monad).bind(add2Monad)\n\nconsole.log(\n  Monad.of(1)\n    .bind(incrementMonad)\n    .bind(add4Monad)\n    .join()\n)\n\nconst add = a =\u003e b =\u003e a + b\nconst add2 = add(2)\n\nlet left = Applicative.of(add2).ap(Applicative.of(3))\nlet right = Applicative.of(3).map(add2)\n\nconsole.log(\n  left.val === right.val // 5\n)\n\n```\n\n## Installation\n\n```\nnpm install --save lowdash\n```\n\n## Usage\nYou can import from `lowdash`:\n\n```js\nimport {compose, curry, pipe, identity, trace, transduce, Functor, Monad, Applicative} from 'lowdash';\n// or\nconst {compose, curry, pipe, identity, trace, transduce, Functor, Monad, Applicative} = require('lowdash');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Flowdash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy2046%2Flowdash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Flowdash/lists"}