{"id":20473526,"url":"https://github.com/xpl/meta-fields","last_synced_at":"2025-08-12T06:13:38.682Z","repository":{"id":57295300,"uuid":"87385185","full_name":"xpl/meta-fields","owner":"xpl","description":"Meta-annotations for data structures in JavaScript","archived":false,"fork":false,"pushed_at":"2017-05-26T10:10:44.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-05T09:41:55.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/meta-fields","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xpl.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":"2017-04-06T04:09:11.000Z","updated_at":"2017-07-19T16:47:53.000Z","dependencies_parsed_at":"2022-08-30T22:30:35.820Z","dependency_job_id":null,"html_url":"https://github.com/xpl/meta-fields","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xpl/meta-fields","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fmeta-fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fmeta-fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fmeta-fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fmeta-fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xpl","download_url":"https://codeload.github.com/xpl/meta-fields/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fmeta-fields/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270011191,"owners_count":24511902,"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-08-12T02:00:09.011Z","response_time":80,"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":[],"created_at":"2024-11-15T14:25:44.975Z","updated_at":"2025-08-12T06:13:38.635Z","avatar_url":"https://github.com/xpl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meta-annotations for data structures in JavaScript\n\n```javascript\nit ('Importing', () =\u003e {\n\n    Meta = require ('./meta-fields')\n})\n\nit ('Defining tags', () =\u003e {\n\n    $foo = Meta.tag ('foo'),\n    $bar = Meta.tag ('bar')\n})\n\nit (\"Defining tags in global namespace\", () =\u003e {\n\n    Meta.globalTag ('qux')\n})\n\nit ('Tag is a function, accepting random data', () =\u003e {\n\n    $foo (42)           // returns 42 tagged with $foo\n    $foo ($bar (42))    // returns 42 tagged with $foo and $bar\n})\n\nit ('It returns a wrapper holding the metadata and the original value', () =\u003e {\n\n    const x = $foo (42)\n\n    assert (Meta.is (x), true)\n\n    assert (            x,   { wrapped: 42, __meta__: { foo: true } })\n    assert (      $bar (x),  { wrapped: 42, __meta__: { foo: true, bar: true } })\n    assert ($qux ($bar (x)), { wrapped: 42, __meta__: { foo: true, bar: true, qux: true } })\n})\n\nit (\"Order/redundancy is irrelevant\", () =\u003e {\n\n    assert ($foo ($bar (42)), $bar ($foo ($foo (42))))\n})\n\nit (\"Supplying additional metadata along with a tag\", () =\u003e {\n\n    assert ($foo ('some data', $bar (42)), { wrapped: 42, __meta__: { foo: 'some data', bar: true } })\n})\n\nit (\"Explicit way of adding tags\", () =\u003e {\n\n    assert (Meta.setTags (42, { foo: true }), $foo (42))\n})\n\nit (\"Accessing the original value\", () =\u003e {\n\n    assert (Meta.unwrap ($foo ($bar (42))), 42)\n    assert (Meta.unwrap (42),               42)\n})\n\nit (\"Modifying tagged value while keeping the original tags intact (can also add new tags this way)\", () =\u003e {\n\n    assert (Meta.modify (      42,  x =\u003e       x + 1),              43)\n    assert (Meta.modify ($foo (42), x =\u003e       x + 1),  $foo (      43))\n    assert (Meta.modify ($foo (42), x =\u003e $bar (x + 1)), $foo ($bar (43)))\n})\n\nit (\"Tagging 'nothing' is legal. And it is not the same as tagging 'undefined'...\", () =\u003e {\n\n    assert ($foo (),          { __meta__: { foo: true } })\n    assert ($foo (undefined), { __meta__: { foo: true }, wrapped: undefined })\n\n    assert (Meta.hasValue ($foo ())         , false)\n    assert (Meta.hasValue ($foo (undefined)), true)\n})\n\nit (\"Checking for a specific tag presence\", () =\u003e {\n\n    assert ($foo.is (      42),  false)\n    assert ($foo.is ($foo (42)), true)\n    assert ($foo.is ($bar (42)), false)\n\n    assert (Meta.hasTag ($foo (42), 'foo'), true)\n})\n\nit (\"Obtaining a value associated with a tag\", () =\u003e {\n\n    assert ($foo.read (              42),   undefined)\n    assert ($foo.read ($foo (        42)),  true)\n    assert ($foo.read ($foo ('data', 42)), 'data')\n\n    assert (Meta.readTag ($foo ('data', 42), 'foo'), 'data')\n})\n\nit (\"Getting all tags\", () =\u003e {\n\n    assert (Meta.tags ($foo ($bar ($qux (42)))), { 'qux': true, 'bar': true, 'foo': true })\n    assert (Meta.tags (                  42),    {})\n})\n\nit (\"Enumerating tags\", () =\u003e {\n\n    const calls = []\n\n    Meta.eachTag ($foo ($bar ($qux (42))), (tag, value) =\u003e calls.push ([tag, value]))\n\n    assert (calls, [['qux', true], ['bar', true], ['foo', true]])\n})\n\nit (\"Removing tags\", () =\u003e {\n\n    assert (Meta.omitTags ($foo ($bar (7)), 'foo'), $bar ( 7))\n    assert (Meta.omitTags (            7,   'foo'),        7)\n})\n\nit (\"Using with string.ify (if available)\", () =\u003e {\n\n    const stringify = require ('string.ify'),\n          pretty    = require ('string.ify').configure ({ pretty: true })\n\n    assert (stringify ( { foo: $foo ($qux ({ bar: 7 }, 1)) }),\n                       '{ foo: $foo ($qux ({ bar: 7 }, 1)) }')\n    \n    assert (pretty ( { foo: $foo ($qux ([ 7, 8 ])) }),\n\n                    '{ foo: $foo ($qux ([ 7,'          + '\\n' +\n                    '                     8  ])) }')\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpl%2Fmeta-fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxpl%2Fmeta-fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpl%2Fmeta-fields/lists"}