{"id":18687284,"url":"https://github.com/junosuarez/node-connective","last_synced_at":"2025-08-22T14:10:05.203Z","repository":{"id":6838355,"uuid":"8086806","full_name":"junosuarez/node-connective","owner":"junosuarez","description":"node module: combine predicate (bool returning) functions with propositional logic connectives (and, or, not)","archived":false,"fork":false,"pushed_at":"2013-02-11T05:30:01.000Z","size":99,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-16T04:07:55.908Z","etag":null,"topics":[],"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/junosuarez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-08T03:22:43.000Z","updated_at":"2019-07-08T22:03:47.000Z","dependencies_parsed_at":"2022-09-12T22:50:46.498Z","dependency_job_id":null,"html_url":"https://github.com/junosuarez/node-connective","commit_stats":null,"previous_names":["agilediagnosis/node-connective"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/junosuarez/node-connective","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-connective","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-connective/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-connective/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-connective/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junosuarez","download_url":"https://codeload.github.com/junosuarez/node-connective/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-connective/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271650860,"owners_count":24796725,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-07T10:32:19.381Z","updated_at":"2025-08-22T14:10:05.125Z","avatar_url":"https://github.com/junosuarez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# connective\ncombine predicate (bool returning) functions with propositional logic connectives (and, or, not)\n\n## installation\n\n    $ npm install connective\n\n## usage\n```js\nvar connective = require('connective')\nvar or = connective.or\nvar and = connective.and\nvar not = connective.not\n\nfunction wearsFlannel (person) {\n  return person.wearing === 'flannel'\n}\n\nfunction ridesBikes (person) {\n  return person.rides === 'bikes'\n}\n\nvar isSquare = not(or(wearsFlannel, ridesBikes))\nvar isHipster = and(wearsFlannel, ridesBikes)\nvar isLumberjack = and(wearsFlannel, not(ridesBikes))\n\nvar people = {\n  jon: { wearing: 'flannel', rides: 'nothing'}\n  kurt: { wearing: 'flannel', rides: 'bikes'}\n  bob: { wearing: 'hoodie', rides: 'scooters'}\n}\n\nfor(var name in people) {\n  var person = people[name]\n  console.log(name, isSquare(person), isHipster(person), isLumberjack(person))\n}\n```\n\n## about\n\nIn propositional logic, boolean statements are joined together by connectives. Logicians would call them conjunctions,  disjunctions, and negations, but programmers know them as `\u0026\u0026`, `||`, and `!`. The problem with using these language-level connective operators is that they apply at evaluation time, and thus aren't very composable.\n\nFunctions which take a value and return a boolean are known as predicates. They are useful, for example, in conditional branching, validation, and business rules.\n\nThe functions in `connective` let you compose predicates into composite expressions which can be used as functions and evaluated later against other data.\n\n## api\n\nIn describing function signatures below, `Predicate` is a function which takes any number of arguments and returns a `boolean`: `function(...) =\u003e boolean`\n\n### `connective.or: function (term1 : Predicate, ..., termN : Predicate) =\u003e Predicate`\n\nReturns a Predicate combining one or more Predicate terms with a logical `or` (disjunction), roughly equivalent to writing\n\n    function (x) { return Predicate1(x) || Predicate2(x) }\n\nThe returned Predicate will pass through its `this` context and arguments to each of the Predicate terms which are necessary to evaluate the expression.\n\n### `connective.and: function (term1 : Predicate, ... termN : Predicate) =\u003e Predicate`\n\nReturns a Predicate combining one or more Predicate terms with a logical `and` (conjunction), roughly equivalent to writing\n\n    function (x) { return Predicate1(x) \u0026\u0026 Predicate2(x) }\n\nThe returned Predicate will pass through its `this` context and arguments to each of the Predicate terms.\n\n### `connective.not: function (term : Predicate) =\u003e Predicate`\n\nReturns a Predicate negating `term`, roughly equivalent to writing\n\n    function (x) { return !Predicate(x) }\n\nThe returned Predicate will pass through its `this` context and arguments to `term`\n\n## running the tests\n\n    $ npm install\n    $ npm test\n\n## contributors\n\njden \u003cjason@denizac.org\u003e\n\n## license\nMIT. (c) 2013 Agile Diagnosis. See LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fnode-connective","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunosuarez%2Fnode-connective","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fnode-connective/lists"}