{"id":16623867,"url":"https://github.com/koleok/cliquer","last_synced_at":"2025-10-29T23:30:21.956Z","repository":{"id":57200446,"uuid":"78449684","full_name":"Koleok/cliquer","owner":"Koleok","description":"Creates a group of related functions from a naming function, a value deriver function, and an array of primitive values.","archived":false,"fork":false,"pushed_at":"2017-12-06T19:21:54.000Z","size":43,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-14T17:22:58.009Z","etag":null,"topics":["clique","es2015","namer","primitive-values","ramda","sanctuary","shorthand"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Koleok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-09T17:00:59.000Z","updated_at":"2023-03-04T05:42:35.000Z","dependencies_parsed_at":"2022-09-16T15:11:36.026Z","dependency_job_id":null,"html_url":"https://github.com/Koleok/cliquer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fcliquer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fcliquer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fcliquer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fcliquer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Koleok","download_url":"https://codeload.github.com/Koleok/cliquer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219857104,"owners_count":16556074,"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":["clique","es2015","namer","primitive-values","ramda","sanctuary","shorthand"],"created_at":"2024-10-12T03:25:15.706Z","updated_at":"2025-10-29T23:30:16.529Z","avatar_url":"https://github.com/Koleok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cliquer\n\nCreates a group of related functions from a naming function, a value deriver function, and an array of primitive values.\n\n# Installation\n\n```bash\nyarn add cliquer\n\n# or\n\nnpm i cliquer\n```\n\n# API\n\n### `clique()`\n```haskell\nclique :: (a -\u003e String) -\u003e (a -\u003e Any) -\u003e Array a -\u003e Object\n```\n\nTakes a namer function, a function to derive a value, and an array of strings that becomes input for both functions, returns an object where each key value pair is generated by [namer, valueDeriver] respectively.\n\n```js\nimport { clique } from 'cliquer';\n\nconst concat = x =\u003e y =\u003e y.concat(x)\nconst always = x =\u003e () =\u003e x\nconst consts = clique(concat('Bar'), always)\n\nconst C = consts(['a', 'b'])\nC.bBar() //=\u003e 'b'\n```\n\n### `simpleClique()`\n```haskell\nsimpleClique :: (a -\u003e Any) -\u003e Array a -\u003e Object\n```\n\nThis is simply [clique](#clique) partially applied with an identity function, so that each key is either a literal or `toString` representation of the input value.\n\n```js\nimport { simpleClique } from 'cliquer';\n\nconst always = x =\u003e () =\u003e x\nconst consts = simpleClique(always)\n\nconst C = consts(['a', 'b'])\nC.b() //=\u003e 'b'\n```\n\n# How and why did this come to be?\n\nCliquer was originally inspired by a utility in [drboolean's lenses](https://github.com/DrBoolean/lenses) library called [`makeLenses`](https://github.com/DrBoolean/lenses/blob/master/src/lenses.js#L70) which takes an array of strings and returns an object of named lenses:\n\n```javascript\nimport { lensProp } from 'ramda'\nimport { makeLenses, view } from 'lenses'\n\nconst obj = {\n  foe: { name: 'marley' },\n  friend: { name: 'me' },\n}\n\n// makeLenses allows a DRY-er approach like\nconst L = makeLenses(['friend', 'name'])\n\n// instead of\nconst friend = lensProp('friend')\nconst name = lensProp('name')\n\nconst friendName = compose(L.friend, L.name)\nview(friendName, obj) // =\u003e 'me'\n```\n\nThis got me thinking, how many things in javascript would benefit from a similar shortcut? So a simple curried factory function was born that took two functions, one to generate the key name, and one to define the function. Turns out this is a super useful pattern for creating utility groups.\n\n```javascript\nimport R from 'ramda'\n\nconst keys = ['beer', 'me']\n\n// Pass an identity function so each key is named literally\nconst simpleClique = clique(x =\u003e x)\n\n// Simple equality checks\nconst eqs = simpleClique(R.equals)\nconst E = eqs(keys)\n\nE.beer('beer') //=\u003e true\nE.me('beer') //=\u003e false\n\n\n// Constant generators\nconst consts = simpleClique(R.always)\nconst C = consts(keys)\n\nC.beer() //=\u003e 'beer'\n\n\n// Regex group\nconst firstChars = simpleClique(x =\u003e new RegExp(`^${x}`))\nconst F = firstChars(['a', 'b'])\n\nR.test(F.a, 'abc') //=\u003e true\nR.test(F.b, 'abc') //=\u003e false\n\n\n/* Even more complex things! */\n\n// Pass a function that names each key by appending `bird`\nconst birdClique =\n  clique(x =\u003e x.concat('bird'))\n\nconst url =\n  'https://isthisbirdathing.com/api/birds'\n\nconst birdFetchers =\n  birdClique(x =\u003e fetch(`${url}/${x}bird`).then(x =\u003e x.json()) )\n\nconst B =\n  birdFetchers(['blue', 'shoe', 'fackle'])\n\nB.facklebird()\n  .then(console.log) //=\u003e { isAThing: 'um.. no' }\n\nB.bluebird()\n  .then(console.log) //=\u003e { isAThing: 'yep 🐦' }\n```\n\nGet the picture? If not submit a PR to help me explain this better or to add more imaginative/hilarious examples 💖\n\n## What are you waiting for? Start some cliques 🍻\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoleok%2Fcliquer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoleok%2Fcliquer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoleok%2Fcliquer/lists"}