{"id":22591897,"url":"https://github.com/georgesalkhouri/ts-specification","last_synced_at":"2025-04-10T23:23:17.558Z","repository":{"id":57381179,"uuid":"58964447","full_name":"GeorgesAlkhouri/ts-specification","owner":"GeorgesAlkhouri","description":"Specification pattern implementation for NodeJS in TypeScript","archived":false,"fork":false,"pushed_at":"2016-09-28T20:36:50.000Z","size":15,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T20:11:26.409Z","etag":null,"topics":["javascript","specification-pattern","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeorgesAlkhouri.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-05-16T20:17:32.000Z","updated_at":"2023-09-18T18:11:52.000Z","dependencies_parsed_at":"2022-09-05T13:40:38.078Z","dependency_job_id":null,"html_url":"https://github.com/GeorgesAlkhouri/ts-specification","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgesAlkhouri%2Fts-specification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgesAlkhouri%2Fts-specification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgesAlkhouri%2Fts-specification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgesAlkhouri%2Fts-specification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeorgesAlkhouri","download_url":"https://codeload.github.com/GeorgesAlkhouri/ts-specification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313228,"owners_count":21082819,"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":["javascript","specification-pattern","typescript"],"created_at":"2024-12-08T09:14:30.899Z","updated_at":"2025-04-10T23:23:17.529Z","avatar_url":"https://github.com/GeorgesAlkhouri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Specification pattern for JavaScript implemented with TypeScript\n================================================================\n\n[![Build Status](https://travis-ci.org/GeorgesAlkhouri/ts-specification.svg?branch=master)](https://travis-ci.org/GeorgesAlkhouri/ts-specification)\n\n\u003e In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic.\n\u003e\n\u003e -- \u003ccite\u003eWikipedia.org ( https://en.wikipedia.org/wiki/Specification_pattern )\u003c/cite\u003e\n\nUsage With Node\n---------------\n\nTo use ts-specification with Node just run:\n\n`npm install ts-specification`\n\nand import the package afterwards:\n\n`import Specification from 'ts-specification'`\n\nThe test cases are written in JavaScript and can be tested with:\n\n`npm test`\n\nCreate Custom Specs\n-------------------\n\nTo create custom specifications just extend from the `CompositeSpecification` class and implement the `isSatisfiedBy` function.\n\n**TypeScript**\n\n```\nclass RangeSpecification\u003cT\u003e extends CompositeSpecification\u003cT\u003e {\n\n  private a: T\n  private b: T\n\n  constructor(a: T, b: T) {\n      super()\n      this.a = a\n      this.b = b\n  }\n\n  isSatisfiedBy(candidate: T): boolean {\n      return candidate \u003e= this.a \u0026\u0026 candidate \u003c= this.b\n  }\n}\n```\n\n**JavaScript**\n\n```\nimport {CompositeSpecification} from 'ts-specification';\n\nclass TrueSpecification extends CompositeSpecification {\n\n    isSatisfiedBy(candidate) {\n        return true;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgesalkhouri%2Fts-specification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgesalkhouri%2Fts-specification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgesalkhouri%2Fts-specification/lists"}