{"id":18084503,"url":"https://github.com/endel/precedence","last_synced_at":"2025-07-27T10:10:39.241Z","repository":{"id":57329675,"uuid":"51256783","full_name":"endel/precedence","owner":"endel","description":"Precedence AND and OR operations for JavaScript.","archived":false,"fork":false,"pushed_at":"2016-02-07T17:40:41.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-05T16:45:24.477Z","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/endel.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}},"created_at":"2016-02-07T17:23:01.000Z","updated_at":"2016-02-07T17:23:11.000Z","dependencies_parsed_at":"2022-09-18T12:13:02.556Z","dependency_job_id":null,"html_url":"https://github.com/endel/precedence","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/endel/precedence","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fprecedence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fprecedence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fprecedence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fprecedence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/endel","download_url":"https://codeload.github.com/endel/precedence/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fprecedence/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267341733,"owners_count":24071770,"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-07-27T02:00:11.917Z","response_time":82,"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-10-31T15:07:01.163Z","updated_at":"2025-07-27T10:10:39.185Z","avatar_url":"https://github.com/endel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"precedence\n===\n\nPrecedence AND and OR operations for JavaScript.\n\nThe problem\n---\n\nSince `\"\"`, `0`, `NaN`, and so on, are considered falsy on expression\nevaluations, sometimes you might get unexpected results.\n\n**Example:**\n\n```\nvar value = false || 0 || \"\" || NaN || 5\nconsole.log(value)\n// =\u003e 5\n```\n\nBut, wait, `0` should've been considered a valid value, shouldn't it? WTF JS TYPES\n\nUsage\n---\n\n`precedence` tackles this problem by considering only `undefined`, `null`, and\n`false` as falsy.\n\n**OR**:\n\n```javascript\nvar or = require('precedence').or\nconsole.log(or(null, false, undefined, 5, 10)) // =\u003e 5\nconsole.log(or(null, \"0\", 5)) // =\u003e \"0\"\nconsole.log(or(null, 0, 5)) // =\u003e 0\n```\n\n**AND**:\n\n```javascript\nvar and = require('precedence').and\nconsole.log(and(null, false, undefined, 5, 10)) // =\u003e false\nconsole.log(and(null, \"0\", 5)) // =\u003e false\nconsole.log(and(null, 0, 5)) // =\u003e false\nconsole.log(and(0, false)) // =\u003e false\n```\n\nLicense\n---\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendel%2Fprecedence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendel%2Fprecedence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendel%2Fprecedence/lists"}