{"id":16371197,"url":"https://github.com/unional/satisfier","last_synced_at":"2025-06-18T11:36:45.533Z","repository":{"id":26933909,"uuid":"111968953","full_name":"unional/satisfier","owner":"unional","description":"Manage and generate artifacts to test data across boundaries","archived":false,"fork":false,"pushed_at":"2025-06-13T20:01:11.000Z","size":6623,"stargazers_count":2,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T02:41:08.597Z","etag":null,"topics":["boundaries","test-automation","testing","testing-tools"],"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/unional.png","metadata":{"files":{"readme":"README.md","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,"zenodo":null},"funding":{"ko_fi":"unional"}},"created_at":"2017-11-25T01:59:04.000Z","updated_at":"2025-03-26T19:41:20.000Z","dependencies_parsed_at":"2023-02-10T22:15:42.635Z","dependency_job_id":"86240792-5c1c-4f4b-b712-254c8915bf30","html_url":"https://github.com/unional/satisfier","commit_stats":{"total_commits":430,"total_committers":7,"mean_commits":61.42857142857143,"dds":"0.37441860465116283","last_synced_commit":"9baa61ed325d7d632b4a1785184999532f78bb1f"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/unional/satisfier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Fsatisfier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Fsatisfier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Fsatisfier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Fsatisfier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unional","download_url":"https://codeload.github.com/unional/satisfier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unional%2Fsatisfier/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260545792,"owners_count":23025800,"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":["boundaries","test-automation","testing","testing-tools"],"created_at":"2024-10-11T03:07:16.272Z","updated_at":"2025-06-18T11:36:40.497Z","avatar_url":"https://github.com/unional.png","language":"TypeScript","funding_links":["https://ko-fi.com/unional"],"categories":[],"sub_categories":[],"readme":"# satisfier\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n\n[![GitHub NodeJS][github-nodejs]][github-action-url]\n[![Codecov][codecov-image]][codecov-url]\n\n[![Semantic Release][semantic-release-image]][semantic-release-url]\n\n[![Visual Studio Code][vscode-image]][vscode-url]\n\nA purposely loose comparison tool.\n\n## Version 5 breaking changes\n\n- Exact check on array\n- No spread on array, use `has()/some()` or `every()`\n- `undefined` now checks against `undefined` instead of a placeholder for anything. Use `anything` for the previous behavior.\n\n## satisfies(actual, expected)\n\nThe simplest way to use `satisfier`.\n\n```ts\nimport { satisfies } from 'satisfier'\n\nsatisfies(1, 1)  // true\nsatisfies({ a: 1 }, { a: v =\u003e v === 1}) // true\nsatisfies([{ a: { b: 'b' }}], [{ a: { b: v =\u003e v === 'b' } }]) // true\n```\n\nCode completion is available to help you quickly creating your expectation.\n\n## createSatisfier(expectation)\n\nEach property in `expectation` can be a value, a `RegExp`, or a predicate function.\n\n### test(actual)\n\nTest `actual` against `expectation`.\n\n```ts\nimport { createSatisfier } from 'satisfier'\n\n// these returns true\ncreateSatisfier({ a: 1 }).test({ a: 1, b: 2 })\ncreateSatisfier({ a: /foo/ }).test({ a: 'foo', b: 'boo' })\ncreateSatisfier({ a: n =\u003e n === 1 }).test({ a: 1, b, 2 })\n\n// these returns false\ncreateSatisfier({ a: 1 }).test({ a: 2 })\ncreateSatisfier({ a: 1, b: 2 }).test({ a: 1 })\ncreateSatisfier({ a: /boo/ }).test({ a: 'foo' })\ncreateSatisfier({ a: () =\u003e false }).test({ a: 1 })\n```\n\n### exec(actual)\n\nCheck `actual` against `expectation` and returns the checking result.\nIf `actual` meets the criteria, returns `null`.\n\n```ts\nimport { createSatisfier } from 'satisfier'\n\n// returns undefined\ncreateSatisfier({ a: 1 }).exec({ a: 1, b: 2 })\ncreateSatisfier({ a: /foo/ }).exec({ a: 'foo', b: 'boo' })\ncreateSatisfier({ a: n =\u003e n === 1 }).exec({ a: 1, b, 2 })\n\n// returns [{ path: ['a'], expected: 1, actual: 2}]\ncreateSatisfier({ a: 1 }).exec({ a: 2 })\n\n// returns [{ path: ['b'], expected: 2, actual: undefined}]\ncreateSatisfier({ a: 1, b: 2 }).exec({ a: 1 })\n\n// returns [{ path: ['a'], expected: /boo/, actual: 'foo'}]\ncreateSatisfier({ a: /boo/ }).exec({ a: 'foo' })\n\n// returns [{ path: ['a'], expected: 'a =\u003e a === 1', actual: 2}]\ncreateSatisfier({ a: a =\u003e a === 1 }).exec({ a: 2 })\n```\n\n## `anything`\n\nIf `anything` is used in expectation, it will match anything.\n\n```ts\nimport { anything } from 'satisfier'\n\ncreateSatisfier(anything).test({})\ncreateSatisfier({ a: anything }).test({})\ncreateSatisfier([anything, 1]).test(['x', 1])\n```\n\n## Test against array\n\nThere are several ways to test against array:\n\n### Using array expectation\n\nWhen you use an array expectation to test against array,\neach entry in the expectation will be used to test against the corresponding entry in the array.\n\nYou can also skip over entries by putting in `anything`.\n\n```ts\nimport { createSatisfier } from 'satisfier'\n\n// all true\ncreateSatisfier([anything, 1]).test(['...anything...', 1])\ncreateSatisfier([e =\u003e e === anything, 1]).test([anything, 1])\n```\n\n### Using predicate expectation\n\nYou can test against the array using a predicate function.\nThe predicate function will receive the whole array.\n\nThis is useful if you want to check the relationship within the array.\n\n```ts\nimport { createSatisfier } from 'satisfier'\n\ncreateSatisfier(\n  a =\u003e\n    Array.isArray(a) \u0026\u0026\n    a.length === 2 \u0026\u0026\n    a[0] === 1 \u0026\u0026\n    a[1] === 2)\n  .test([1, 2])\n```\n\n### Using primitive and object expectation\n\nWhen the expectation is a primitive value or an object,\nit will be used to check against each element in the array.\n\n```ts\nimport { createSatisfier } from 'satisfier'\n\n// true\ncreateSatisfier(1).test([1, 1])\ncreateSatisfier(false).test([false, false])\ncreateSatisfier('a').test(['a', 'a'])\ncreateSatisfier({ a: e =\u003e typeof e === 'string' })\n  .test([{ a: 'a' }, { a: 'b' }]))\n\n```\n\n## Build in predicates\n\nThere are a few predicates shipped in the package for convenience.\nThey all support [`tersify`](https://github.com/unional/tersify).\nThis means if you use `tersify` to print the predicate (e.g. for logging purpose),\nyou will get a terse string representing the predicates.\n\nFor example:\n\n```ts\nimport { createSatisfier, isInRange } from 'satisfier'\n\nconst results = createSatisfier(isInRange(1, 3)).exec(0)\n\n// prints '[1...3]'\nresults[0].expected.tersify()\n// { path: [], expected: [1...3], actual: 0 }\ntersify(results[0])\n```\n\nExamples of predicate: `every`, `has`, `isInInterval`, `isInRange`, `isTypeOf`, `none`, `some`, `startsWith`\n\n## Contribute\n\n```sh\n# after fork and clone\nnpm install\n\n# begin making changes\ngit checkout -b \u003cbranch\u003e\nnpm run watch\n\n# after making change(s)\ngit commit -m \"\u003ccommit message\u003e\"\ngit push\n\n# create PR\n```\n\n[codecov-image]: https://codecov.io/gh/unional/satisfier/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/unional/satisfier\n[downloads-image]: https://img.shields.io/npm/dm/satisfier.svg?style=flat\n[downloads-url]: https://npmjs.org/package/satisfier\n[github-action-url]: https://github.com/unional/satisfier/actions\n[github-nodejs]: https://github.com/unional/satisfier/workflows/nodejs/badge.svg\n[npm-image]: https://img.shields.io/npm/v/satisfier.svg?style=flat\n[npm-url]: https://npmjs.org/package/satisfier\n[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\n[vscode-image]: https://img.shields.io/badge/vscode-ready-green.svg\n[vscode-url]: https://code.visualstudio.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funional%2Fsatisfier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funional%2Fsatisfier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funional%2Fsatisfier/lists"}