{"id":18730068,"url":"https://github.com/b-gran/immutable-record","last_synced_at":"2025-09-20T07:57:22.753Z","repository":{"id":57272838,"uuid":"74702652","full_name":"b-gran/immutable-record","owner":"b-gran","description":"Typed immutable Records inspired by ImmutableJS","archived":false,"fork":false,"pushed_at":"2018-04-05T18:49:48.000Z","size":61,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T03:07:08.937Z","etag":null,"topics":["immutable","immutable-record","immutablejs","record","typed"],"latest_commit_sha":null,"homepage":"https://b-gran.github.io/immutable-record/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b-gran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-24T20:18:14.000Z","updated_at":"2020-12-20T16:28:36.000Z","dependencies_parsed_at":"2022-09-12T07:54:10.638Z","dependency_job_id":null,"html_url":"https://github.com/b-gran/immutable-record","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/b-gran/immutable-record","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b-gran%2Fimmutable-record","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b-gran%2Fimmutable-record/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b-gran%2Fimmutable-record/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b-gran%2Fimmutable-record/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b-gran","download_url":"https://codeload.github.com/b-gran/immutable-record/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b-gran%2Fimmutable-record/sbom","scorecard":{"id":221813,"data":{"date":"2025-08-11","repo":{"name":"github.com/b-gran/immutable-record","commit":"ff8f6021ab1a8cb5f2b4cd62d69608cd37376582"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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-17T02:43:07.805Z","repository_id":57272838,"created_at":"2025-08-17T02:43:07.805Z","updated_at":"2025-08-17T02:43:07.805Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276064356,"owners_count":25578999,"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","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["immutable","immutable-record","immutablejs","record","typed"],"created_at":"2024-11-07T14:34:30.194Z","updated_at":"2025-09-20T07:57:22.730Z","avatar_url":"https://github.com/b-gran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## `immutable-record` -- typed \u0026 immutable Javascript objects\n\n[![Build Status](https://travis-ci.org/b-gran/immutable-record.svg?branch=master)](https://travis-ci.org/b-gran/immutable-record) [![npm version](https://badge.fury.io/js/immutable-record.svg)](https://badge.fury.io/js/immutable-record)\n\n`immutable-record` is a small JavaScript library inspired by Facebook's ImmutableJS\nthat allows you to create immutable `Records`.\n`Records` behave very much like Objects (even `Object.keys()`), but they are \ntyped and immutable.\n\n### What does it look like?\n\n```\n// ImmutableRecord() returns a Record class\nimport ImmutableRecord from 'immutable-record'\nconst Record = ImmutableRecord({\n  foo: { default: 5 },\n  optional: { type: 'number' }\n  someField: {\n    type: value =\u003e 'foo' in value,\n    required: true\n  },\n})\n\n// You just pass ordinary objects to the Record constructor\nconst object = new Record({\n  someField: { foo: 'bar' }\n  // You don't have to provide optional fields\n})\n\n// Object.keys() works as if the Record was a normal Object\nObject.keys(object) // [ 'foo', 'someField' ]\n\n// Records are immutable, so Record#set() returns a new Record\nconst another = object.set('optional', 8)\nanother.optional // 8\n\n// Validation happens automatically\nobject.remove('someField')\n// Error: \"someField\" is missing from the record {\"foo\":5}\n\n```\n\n### Why pick `immutable-record` ?\n\nCompared to ImmutableJS, the key feature is __automatic validation.__ With \n`immutable-record`, you can specify a type of each field and it will be \nautomatically checked. Additionally:\n\n* `Object.keys()` works just how you would expect\n* You can mark fields as `required`\n* You can create optional fields that may not be present on a record, but will \nvalidate when set.\n\n## Documentation\n\n### Installing\n\n```\n# immutable-record is available on npm\nnpm install --save immutable-record\n```\n\n### Importing\n\n```\nimport ImmutableRecord from 'immutable-record'\n\n// If you're not using ES6 modules\nconst ImmutableRecord = require('immutable-record')\n```\n\n### Creating Records\n\nThe ImmutableRecord() function takes an object whose values describe the \nvalidation that is applied to the fields.\n\n```\nconst Record = ImmutableRecord({\n  optional: { type: 'string' },\n  required: { required: true },\n  validation: {\n    type: value =\u003e value \u003e 5,\n    default: 6\n})\n```\n\nYou can also pass a second parameter to the ImmutableRecord() function\nwhich specifies a custom name for the Record class.\n\n```\nconst Foo = ImmutableRecord({\n    foo: { type: 'string' }\n}, 'Foo')\nFoo.name === 'Foo' // true\nconsole.log(Foo) // [Function: Foo]\n```\n\nThere are three validation options available for each field:\n\u003e \u003e `type`, `required`, and `default`\n\n#### The `type` option\n\n1. A primitive string (AKA one of the values returned by typeof). The possible \nvalues at the time of writing are:\n\u003e \u003e 'object', 'string', 'number', 'symbol', 'boolean',\nfunction', 'undefined'\n\n2. A validation function that takes a single argument (the field's value) and \nreturns a boolean.\n\n```\nconst Record = ImmutableRecord({\n  // Strings (typeof x === 'string') are valid\n  string: { type: 'string' },\n\n  // Arrays of length 4 or greater are valid\n  array: {\n    type: value =\u003e (\n      Array.isArray(value) \u0026\u0026\n      value.length \u003e 3\n    )\n  }\n})\n```\n\n#### The `default` option\n\nIf a field has a default and a Record is created without the field explicitly set,\nthe default value is used automatically.\n\n```\nconst Record = ImmutableRecord({\n  withDefault: { default: 5 }\n})\n\n// The default is automatically used if the field isn't set\nconst object = new Record({})\nobject.withDefault // 5\n\n// undefined is a legal field value, so the default won't be used\nconst noDefault = new Record({\n  withDefault: undefined\n})\nnoDefault.withDefault // undefined\n```\n\n#### The `required` option\n\nFields marked as \"required\" must be present on the Record for it to validate.\n\n```\nconst Record = ImmutableRecord({\n  required: { required: true },\n  optional: { required: false }\n})\n\n// No problems here\nconst object = new Record({\n  required: 1\n})\n'optional' in object // false\n\n// This doesn't work\nconst bad = new Record({\n  optional: 1\n})\n// Error: \"required\" is missing from the record {\"optional\":1}\n```\n\nIf a field is required and it also has a default, the Record will still validate\neven if the field isn't set.\n\n```\nconst Record = ImmutableRecord({\n  field: {\n    required: true,\n    default: 5\n  }\n})\n\n// No problems here\nconst object = new Record({})\nobject.field // 5\n```\n\n#### Fields with no options\n\nYou can also leave the options out to get optional, untyped fields.\n\n```\nconst Record = ImmutableRecord({\n  optionalUntyped: {},\n\n  // setting the field equal to null works too\n  alsoWorks: null\n})\n```\n\n### Using Records\n\nRecords mostly work just like normal Objects, except they're immutable.\n\n```\nconst ABCRecord = ImmutableRecord({\n  a: {}, b: {}, c: {}\n})\n\nconst object = new ABCRecord({ a: 1, c: 3 })\nobject.a // 1\nobject.c // 3\nobject.b // undefined\n'b' in object // false\n\n// Object.keys() also works how you would expect\nObject.keys(object) // [ 'a', 'c' ]\n```\n\nWhen you try to set or delete a Record's value directly, the Record will throw.\n\n```\nconst object = new ABCRecord({ a: 1, c: 3 })\n\nobject.b = 2\n// Error: Use the \"set\" function to update the values of an ImmutableRecord.\n\ndelete object.a\n// TypeError: Cannot delete property 'a' of [object Object]\n```\n\n#### `Record#set()`\n\nUse the `set()` function to update Record values. `set()` returns a new Record instance.\n\n```\nconst object = new ABCRecord({ a: 1, c: 3 })\n\nconst withB = object.set('b', 2)\nwithB instanceof ABCRecord // true\nwithB.b // 2\n\n// The original record is unmodified\nobject.b // undefined\n```\n\n#### `Record#remove()`\n\nUse the `remove()` function to remove Record values. `remove()` returns a new Record instance.\n\n```\nconst object = new ABCRecord({ a: 1, b: 2, c: 3 })\n\nconst withoutB = object.remove('b')\nwithoutB instanceof ABCRecord // true\nwithoutB.b // undefined\n```\n\n#### A point about validation\n\nRecords are validated when they are constructed, so all of your fields will be validated\nwhen you use `set()` and `remove()`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb-gran%2Fimmutable-record","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb-gran%2Fimmutable-record","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb-gran%2Fimmutable-record/lists"}