{"id":21662503,"url":"https://github.com/alvarobernalg/logical-operators","last_synced_at":"2026-05-17T12:11:06.022Z","repository":{"id":86319010,"uuid":"95160077","full_name":"AlvaroBernalG/logical-operators","owner":"AlvaroBernalG","description":"Abstracts logical operators into functions with the intention of improving code readability.","archived":false,"fork":false,"pushed_at":"2017-06-30T11:22:41.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T07:02:31.858Z","etag":null,"topics":["every","javascript","logical","logical-operators","nodejs","operators","or","readability"],"latest_commit_sha":null,"homepage":"","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/AlvaroBernalG.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-06-22T22:02:35.000Z","updated_at":"2017-06-23T11:54:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff86e75c-8a09-47e3-8784-4e34730d3ab8","html_url":"https://github.com/AlvaroBernalG/logical-operators","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"b7c259ea38efe4eaa369436dfd8f710600940c5d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlvaroBernalG%2Flogical-operators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlvaroBernalG%2Flogical-operators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlvaroBernalG%2Flogical-operators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlvaroBernalG%2Flogical-operators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlvaroBernalG","download_url":"https://codeload.github.com/AlvaroBernalG/logical-operators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244532796,"owners_count":20467748,"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":["every","javascript","logical","logical-operators","nodejs","operators","or","readability"],"created_at":"2024-11-25T10:16:31.719Z","updated_at":"2026-05-17T12:11:00.981Z","avatar_url":"https://github.com/AlvaroBernalG.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logical-operators\n\n\u003e A tiny library that abstracts away logical operators with the intention of improving code readability. Ideal for composing complex validation queries. \n\n[![Build Status](https://travis-ci.org/AlvaroBernalG/logical-operators.svg?branch=master)](https://travis-ci.org/AlvaroBernalG/logical-operators) [![npm version](https://badge.fury.io/js/logical-operators.svg)](https://badge.fury.io/js/logical-operators) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## [](#i-disagree-with-rule-x-can-you-change-it)\n\n## Install\n```\n$ npm install logical-operators --save\n```\n\n## Usage\n\n### every ( \u0026\u0026 )...\n\n```js\nconst { every } = require('logical-operators')\nconst is = require('library-that-validate-stuff')\n\nconst values = [1, 9, 7,'level', 'Venezuela', 'Caracas', 'Aba', 'hola', 10, undefined, 'USA']\n\nconst palindromeCities = every(is.string, is.palindrome, is.city)\n\nvalues.filter(palindromeCities) // =\u003e ['Aba']\n\nvalues.every(palindromeCities) // =\u003e false\n  \nvalues.some(palindromeCities) // =\u003e true\n\n```\n\n### some ( || ) ...\n```js\n\nconst { some } = require('logical-operators')\nconst between = require('in-between')\nconst is = require('library-that-validate-stuff')\n\nconst values = ['a','b','two', 'd', 'x', 3, undefined, null,'three']\n\n \nvalues.every(some(between('w','z'), is.number, between('a','c'))) // =\u003e false\n\nvalues.filter(some(between('w','z'), is.number, between('a','c'))) // =\u003e ['b', 3, 'x']\n\n```\n\n### or  ( || )\n\nSame as 'some' but only accepts 2 params\n\n```js\nconst { or } = require('logical-operators')\nconst is = require('library-that-validate-stuff')\n\nconst values = [1,2,'three']\n\nconst string_or_number = or(is.string, is.number)\n\nvalues.every(string_or_number) // =\u003e true\n\nvalues.filter(string_or_number) // =\u003e [1, 2, 'three']\n\n```\n\n### both  ( \u0026\u0026 )\n\nSame as 'every' but only accepts 2 params\n```js\n\nconst { both } = require('logical-operators')\nconst is = require('library-that-validate-stuff')\n\nconst values = ['a','b','two']\n\nconst string_and_singleChar = both(is.string, is.singleChar)\n\nvalues.every(string_and_singleChar) // =\u003e false\n\nvalues.filter(string_and_singleChar) // =\u003e ['a','b']\n\n```\n\n### equal  ( == ) \n\n```js\nconst { equal, greater } = require('logical-operators')\nconst is = require('library-that-validate-stuff')\nconst compose = require('lodash/compose')\n\nvar getAsciiSum = (str) =\u003e str.split('').map(char =\u003e char.charCodeAt(0)).reduce((prev, next)=\u003e prev+ next,0)\n\nvar values = [1,2,3, 'ab', 'e', 'T', 'W', '/']\n\nvalues.every(\n    is.string,\n    equal(getAsciiSum, compose(greater(102).than, toAscii) ),\n  ) // =\u003e false\n\nvalues.filter(\n    is.string,\n    equal(getAsciiSum, compose(greater(100).than, toAscii) ),\n  ) // =\u003e ['ab', 'e']\n\n```\n\n\n\n\u003c!-- ### greater  ( \u003e ) --\u003e\n\u003c!--  --\u003e\n\u003c!-- ```js --\u003e\n\u003c!--  --\u003e\n\u003c!-- const { both } = require('logical-operators') --\u003e\n\u003c!-- const is = require('library-that-validate-stuff') --\u003e\n\u003c!--  --\u003e\n\u003c!-- const values = ['a','b','two'] --\u003e\n\u003c!--  --\u003e\n\u003c!-- const greaterThan2 = greater(2).than --\u003e\n\u003c!--  --\u003e\n\u003c!-- values.every(greaterThan2) // =\u003e false --\u003e\n\u003c!--  --\u003e\n\u003c!-- values.filter(string_and_singleChar) // =\u003e ['a','b'] --\u003e\n\u003c!--  --\u003e\n\u003c!-- ``` --\u003e\n\n\n## License\n\nMIT © [Alvaro Bernal](https://github.com/AlvaroBernalG/) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarobernalg%2Flogical-operators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falvarobernalg%2Flogical-operators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarobernalg%2Flogical-operators/lists"}