{"id":17999568,"url":"https://github.com/ozum/fix-set","last_synced_at":"2025-04-04T07:15:04.331Z","repository":{"id":19006061,"uuid":"85798687","full_name":"ozum/fix-set","owner":"ozum","description":"Lets you define prefix and suffix rules to test strings against.","archived":false,"fork":false,"pushed_at":"2024-04-16T03:11:36.000Z","size":275,"stargazers_count":0,"open_issues_count":18,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T07:06:23.292Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/ozum.png","metadata":{"files":{"readme":"README.hbs","changelog":"CHANGELOG.md","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-03-22T07:36:46.000Z","updated_at":"2019-11-03T04:36:59.000Z","dependencies_parsed_at":"2024-10-29T22:53:58.805Z","dependency_job_id":null,"html_url":"https://github.com/ozum/fix-set","commit_stats":{"total_commits":67,"total_committers":2,"mean_commits":33.5,"dds":"0.014925373134328401","last_synced_commit":"09face1a0823fe414ec296f0200fd4e3fd5106ae"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Ffix-set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Ffix-set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Ffix-set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Ffix-set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozum","download_url":"https://codeload.github.com/ozum/fix-set/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135147,"owners_count":20889421,"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":[],"created_at":"2024-10-29T22:13:43.417Z","updated_at":"2025-04-04T07:15:04.307Z","avatar_url":"https://github.com/ozum.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- DO NOT EDIT README.md (It will be overridden by README.hbs) --\u003e\n\n# fix-set\n\n\u003c!-- START doctoc --\u003e\n\u003c!-- END doctoc --\u003e\n\n# Description\n\n`fix-set` module lets you define simple prefix, suffix and exception rules and test strings against those rules.\n\nPossible use cases:\n\n* Filter query parameters from a web form.\n* Filter custom HTTP header fields.\n\n## Rule Priority\n\n* Rules: `exclude` \u003e `include`\n* Inside Rules: `except` \u003e `elements` \u003e `exceptPrefixes` or `exceptSuffixes` \u003e `prefixes` or `suffixes`\n* Prefixes and suffixes has `or` relation. If a string satisfies one of them, rule is satisfied.\n* If no `prefixes` and `suffixes` provided, it is assumed all strings are included in rule except `exceptPrefixes` and `exceptSuffixes`.\n\n# Synopsis\n\n**TypeScript**\n```js\nimport FixSet, { RuleConfig, FixSetConfig } from 'fix-set';\n```\n\n**JavaScript**\n```js\nimport FixSet from 'fix-set';\n```\n\n--------------\n\n```js\n// Whitelist: Include only strings starting with 'q' but not 'qX'.\nconst fixSet = new FixSet({\n  include: {\n    prefixes:       'q',\n    exceptPrefixes: 'qx',\n    replacePrefix:  true,\n    replaceSuffix:  true\n  }\n});\n\nconst name       = fixSet.getName('qMemberName');   // 'MemberName'\nconst has        = fixSet.has('qMemberName');       // true\nconst otherField = fixSet.getName('qxOther');       // undefined\nconst otherHas   = fixSet.has('qxOther');           // false\n```\n\n```js\n// Blacklist: Include all strings excluding which begins with 'q',\n// but include strings beginning with 'qX' even they also begin with 'q'.\nconst fixSet = new FixSet({\n  exclude: {\n    prefixes:       'q',\n    exceptPrefixes: 'qx',\n    replacePrefix:  true,\n    replaceSuffix:  true\n  }\n});\n\nconst name       = fixSet.getName('qMemberName');   // undefined\nconst has        = fixSet.has('qMemberName');       // false\nconst otherField = fixSet.getName('qxOther');       // Other\nconst otherHas   = fixSet.has('qxOther');           // true\n```\n\n```js\n  // Usage with Array#filter, Array#map etc.\n  // Get included field names.\n  const parameters = Object.keys(formParameters).filter(param =\u003e fixSet.has(param));\n  const dbFields   = Object.keys(formParameters)\n    .map(param =\u003e fixSet.getName(param))\n    .filter(field =\u003e field !== undefined);\n```\n\n```js\n// Usage with lodash.\nimport lodash from 'lodash';\nconst filteredObject = lodash.pickBy(data, (value, key) =\u003e fixSet.has(key));\n```\n\n```js\n// Cover only strings starting with 'q' or /^=(.+?)=/.\nconst fixSet = new FixSet({\n  include: {\n    prefixes:      ['q', /^=(.+?)=/],\n    replacePrefix: true,\n    replaceSuffix: true\n  }\n});\nconst name = fixSet.getName('qMemberName');     // 'MemberName'\nconst has  = fixSet.has('qMemberName');         // true\nconst has  = fixSet.has('=eq=MemberName');      // true\nconst has  = fixSet.getName('=eq=MemberName');  // 'MemberName'\n```\n\n## Why both `include` and `exclude`?\n\nConsider two scenarios below:\n\n* Include all strings, but not starting with 'q'. However include starting with 'qx': `{ exclude: { prefixes: 'q', exceptPrefixes: 'qx' } }`\n* Exclude all strings, but not starting with 'q'. However exclude starting with 'qx' `{ include: { prefixes: 'q', exceptPrefixes: 'qx' } }`\n\n# API\n{{\u003emain~}}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozum%2Ffix-set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozum%2Ffix-set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozum%2Ffix-set/lists"}