{"id":22021452,"url":"https://github.com/lamansky/mix-in","last_synced_at":"2026-04-18T17:02:43.357Z","repository":{"id":57298565,"uuid":"114903628","full_name":"lamansky/mix-in","owner":"lamansky","description":"[Node.js] Turns a set of functions into a mix-in/trait that can extend a class.","archived":false,"fork":false,"pushed_at":"2018-02-04T12:50:56.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-24T18:55:17.663Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamansky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-20T15:38:35.000Z","updated_at":"2017-12-20T16:21:01.000Z","dependencies_parsed_at":"2022-08-26T18:02:29.600Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/mix-in","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lamansky/mix-in","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmix-in","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmix-in/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmix-in/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmix-in/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/mix-in/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fmix-in/sbom","scorecard":{"id":577787,"data":{"date":"2025-08-11","repo":{"name":"github.com/lamansky/mix-in","commit":"6f92180cb47d3b48cac9207c0c6d2c750616bd0c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/5 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license.txt:0","Info: FSF or OSI recognized license: MIT License: license.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T18:18:18.643Z","repository_id":57298565,"created_at":"2025-08-20T18:18:18.643Z","updated_at":"2025-08-20T18:18:18.643Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31976805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T16:27:12.723Z","status":"ssl_error","status_checked_at":"2026-04-18T16:27:11.140Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-30T06:12:07.540Z","updated_at":"2026-04-18T17:02:43.336Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mix-in\n\nTurns a set of functions into a mix-in/trait that can extend a class.\n\n## Installation\n\nRequires [Node.js](https://nodejs.org/) 7.0.0 or above.\n\n```bash\nnpm i mix-in\n```\n\n## Basic Usage\n\n### Step 1: Define the Mix-In\n\nLet’s say you want to create a module that adds `enable()` and `disable()` methods to a class. Your module would `require('mix-in')` and look like this:\n\n```javascript\nconst Mixin = require('mix-in')\n\nmodule.exports = Mixin({\n  enable () {\n    // TODO\n  },\n\n  disable () {\n    // TODO\n  },\n})\n```\n\nThis is all you need to do for your mix-in module. Easy enough, right? Now we’ll turn to the module that makes use of your new mix-in.\n\n### Step 2: Require and Apply the Mix-In\n\nLet’s say you have a second module that exports a `Button` class and you want to extend it with your mix-in module from step 1, which you named `@lamansky/enable-disable-mix-in`.\n\n```javascript\nmodule.exports = class Button {\n  // Methods go here\n}\n```\n\nAll you have to do in the dependent module is:\n1. Require the mix-in.\n2. Call it as a function without arguments.\n3. Call it again, passing the class as an argument.\n\nLike so:\n\n```javascript\n// Note the function call at the end of this line; you need to have that!\nconst EnableDisable = require('@lamansky/enable-disable-mix-in')()\n\nmodule.exports = EnableDisable(class Button {\n  // This class now has enable() and disable() methods!\n})\n```\n\nThat’s it! Your `Button` class prototype now has `enable()` and `disable()` methods.\n\n## Advanced Usage: Parameters\n\nYou can also create mix-ins that accept arguments. This is useful for creating configurable mix-ins, or mix-ins that access private properties using symbols.\n\n### Step 1: Define the Mix-In\n\nInstead of defining your mix-in as an object, we’ll create a function that takes arguments. Let’s modify our previous mix-in so that it makes use of a symbol:\n\n```javascript\nconst Mixin = require('mix-in')\n\nmodule.exports = Mixin(_enabled =\u003e ({\n  enable () {\n    this[_enabled] = true\n  },\n\n  disable () {\n    this[_enabled] = false\n  },\n}))\n```\n\n### Step 2: Require and Apply the Mix-In\n\nNow do the following in the dependent module:\n1. Require the mix-in.\n2. Call it as a function, passing the arguments your mix-in is expecting.\n3. Call it again, passing the class as an argument.\n\n```javascript\nconst _enabled = Symbol('enabled')\nconst EnableDisable = require('@lamansky/enable-disable-mix-in')(_enabled)\n\nmodule.exports = EnableDisable(class Button {\n})\n```\n\nJust like before, your `Button` now has `enable()` and `disable()` in its prototype, except this time, both your `Button` class and your mix-in have access to the same `_enabled` symbol.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fmix-in","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fmix-in","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fmix-in/lists"}