{"id":18552526,"url":"https://github.com/andrejewski/hyponym","last_synced_at":"2025-05-15T11:13:27.143Z","repository":{"id":20063689,"uuid":"23332375","full_name":"andrejewski/hyponym","owner":"andrejewski","description":"subtypes for JavaScript objects and primitives","archived":false,"fork":false,"pushed_at":"2014-10-12T01:54:52.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-26T08:27:25.461Z","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":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrejewski.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":"2014-08-25T23:42:22.000Z","updated_at":"2019-03-28T16:38:50.000Z","dependencies_parsed_at":"2022-09-02T13:41:50.341Z","dependency_job_id":null,"html_url":"https://github.com/andrejewski/hyponym","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fhyponym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fhyponym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fhyponym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fhyponym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrejewski","download_url":"https://codeload.github.com/andrejewski/hyponym/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239278508,"owners_count":19612329,"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-11-06T21:14:28.189Z","updated_at":"2025-02-17T10:43:42.620Z","avatar_url":"https://github.com/andrejewski.png","language":"JavaScript","readme":"Hyponym\n=======\n\nHyponym brings powerful subtypes to JavaScript. Inspired by Haskell's type system, Hyponym is capable of expressing monads and other such constructs along with the more simple literal data types and primitives of JavaScript.\n\n```bash\nnpm install hyponym\n```\n\nHyponym is designed to have a very simple API and even provides a prelude of common types that you might need everyday.\n\n```javascript\nvar Hyponym = require('hyponym');\n\nvar number = 1890,\n\tstring = \"kevin spacey\",\n\tobject = {};\n\nHyponym.Number.validate(number); // true\nHyponym.Number.validate(string); // false\n\nHyponym.String.validate(string); // true\nHyponym.String.validate(object); // false\n\nHyponym.Object.validate(object); // true\nHyponym.Object.validate(number); // false\n```\n\n## Reference\n\n### Class Methods\n\n```javascript\nHyponym(options) -\u003e Hyponym instance\nHyponym.baseType(type) -\u003e Hyponym instance \n```\n\n### Instance Methods\n\n```javascript\nHyponym#name() -\u003e String\nHyponym#subtype(options) -\u003e Hyponym instance\nHyponym#supertype() -\u003e Hyponym instance\nHyponym#validate(value Any) -\u003e Boolean\nHyponym#assert(value Any, returns Boolean):\n\tif not Hyponym.validate(value)\n\t\tif returns then returns Error\n\telse throws Error\nHyponym#serialize(value Any) -\u003e Any\n```\n\n### Prelude\n\n#### Primitive Types\nPrimitive types can be found on the Hyponym namespace directly, such as `Hyponym.Number`.\n\n- Number\n- String\n- Boolean\n- Object\n- Date\n- Array\n- RegExp\n- Function\n- Error\n\n#### Complex Types\nComplex types can be required from Hyponym by requiring them from the `lib` directory, like so:\n\n```javascript\nvar Alphanumeric = require('hyponym/lib/alphanumeric'),\n\tArrayList = require('hyponym/lib/array-list');\n```\n\n- Alphanumberic\n- ArrayList\n- Choice (one of a list of types)\n- Either\n- Email\n- Integer\n- Maybe\n- Range\n- Struct\n- Tuple\n\nIs your favorite type missing? Open an issue and I'll see what I can do for you. Or go pro and submit an implementation of your own. (See Contributing.)\n\n## Contributing\n\nContributions are incredibly welcome as long as they are standardly applicable and pass the tests (or break bad ones). Tests are written in Mocha and assertions are done with the Node.js core `assert` module.\n\n```bash\n# running tests\nnpm run test\n```\n\nFollow me on [Twitter](https://twitter.com/compooter) for updates or just for the lolz and please check out my other [repositories](https://github.com/andrejewski) if I have earned it. I thank you for reading.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fhyponym","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrejewski%2Fhyponym","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fhyponym/lists"}