{"id":16189397,"url":"https://github.com/caolan/behaviors","last_synced_at":"2025-03-19T03:30:53.411Z","repository":{"id":823660,"uuid":"537695","full_name":"caolan/behaviors","owner":"caolan","description":"A (really) simple way to check a modules export's in node.js. Inspired by behaviors in Erlang.","archived":false,"fork":false,"pushed_at":"2011-11-21T17:42:55.000Z","size":93,"stargazers_count":10,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T03:11:28.411Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/caolan.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":"2010-02-26T18:24:26.000Z","updated_at":"2025-02-06T04:18:33.000Z","dependencies_parsed_at":"2022-08-16T11:00:51.533Z","dependency_job_id":null,"html_url":"https://github.com/caolan/behaviors","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/caolan%2Fbehaviors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fbehaviors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fbehaviors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fbehaviors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caolan","download_url":"https://codeload.github.com/caolan/behaviors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244350905,"owners_count":20439289,"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-10T07:35:19.822Z","updated_at":"2025-03-19T03:30:53.144Z","avatar_url":"https://github.com/caolan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Behaviors\n=========\n\nA (really) simple way to check a modules exports in node.js.\n\nThis module is useful for projects implementing a plugin-style API, where\nwarning the developer of missing or invalid exports is more friendly than\nsimply starting up a server and letting all hell break loose.\n\nThis approach is similar to behaviors in Erlang (hence the name), where\na module is checked for required callbacks at compile time. In this case,\nwe check a module when it is require()'d.\n\n\nUsage\n-----\n\nAn example behavior description module (it could also just be an object):\n\n    exports.id = [Number, String];\n    exports.name = [String, undefined];\n    exports.init = Function;\n    exports.reserved = undefined;\n\nA module implementing this behavior MUST export an id of type Number or String,\nand an init function. It MUST NOT export 'reserved' (unless it exports\nundefined as its value). It MAY export name, which must be a string.\n\nUsing a behavior description:\n\n    var behaviors = require('behaviors');\n    var plugin_behavior = require('./behaviors/plugin_behavior');\n\n    var plugin1 = behaviors.require('./plugins/plugin1', plugin_behavior);\n\nIn the above example, an exception will be thrown if plugin1 does not meet\nthe requirements defined in plugin_behavior. The exception message will show\nsome useful information on whether an expected property was the wrong type\nor missing.\n\n\nSupported Export Types\n----------------------\n\n* Boolean\n* Function\n* Number\n* Object\n* String\n* null\n* undefined\n\n\nTests\n-----\n\nTo run the tests you'll need to get testrunner, which is a submodule in this\nrespository. This can be done by the following commands:\n\n    git submodule init\n    git submodule update\n\nThe tests can then be run by doing:\n\n    node test.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaolan%2Fbehaviors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaolan%2Fbehaviors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaolan%2Fbehaviors/lists"}