{"id":21391617,"url":"https://github.com/multiprocessio/shape","last_synced_at":"2025-07-13T18:30:38.905Z","repository":{"id":46491920,"uuid":"390372040","full_name":"multiprocessio/shape","owner":"multiprocessio","description":"Basic schema inference for arbitrary JavaScript data objects","archived":false,"fork":false,"pushed_at":"2022-01-02T20:50:46.000Z","size":571,"stargazers_count":34,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-03-03T23:04:35.017Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multiprocessio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-28T14:01:56.000Z","updated_at":"2023-03-02T03:21:02.000Z","dependencies_parsed_at":"2022-09-17T16:02:04.349Z","dependency_job_id":null,"html_url":"https://github.com/multiprocessio/shape","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fshape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fshape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fshape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fshape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multiprocessio","download_url":"https://codeload.github.com/multiprocessio/shape/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225906291,"owners_count":17543131,"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-22T13:35:05.878Z","updated_at":"2024-11-22T13:35:06.564Z","avatar_url":"https://github.com/multiprocessio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shape\n\nThis library provides an inference of object shape given a JavaScript\ndata object. It probably won't work well with circular references. But\nany object that comes from JSON will not have circular references.\n\nIt works well on very small or very large objects due to sampling\n(which can be turned off if requested).\n\nYou can try it out online in the [DataStation app](https://app.datastation.multiprocess.io/).\n\n![screenshot](./screenshot.png)\n\n## Install\n\n```bash\n$ yarn add @multiprocess/shape\n```\n\n## Examples\n\n```javascript\nimport { shape, toString } from '@multiprocess/shape';\n\nconst schema = shape({\n  \"results\": [\n    { \"name\": \"Kevin\", \"score\": \"1\" },\n    { \"name\": \"Moira\", \"score\": 1 },\n    { \"name\": \"Alexei\", \"score\": 2 },\n    { \"name\": \"Tia\", \"score\": 2, \"admin\": true }\n  ],\n  \"pageSize\": 5,\n  \"total\": 100,\n  \"nextPage\": \"https://myapi.com/p=2\",\n});\nconsole.log(JSON.stringify(schema, null, 2), toString(schema));\n```\n\nWill print out:\n\n```\n{    \n  \"kind\": \"object\",\n  \"children\": {\n    \"results\": {\n      \"kind\": \"array\",\n      \"children\": {\n        \"kind\": \"object\",\n        \"children\": {\n          \"name\": {\n            \"kind\": \"scalar\",\n            \"name\": \"string\"\n          },      \n          \"score\": {\n            \"kind\": \"varied\",\n            \"children\": [\n              {\n                \"kind\": \"scalar\",\n                \"name\": \"string\"\n              },\n              {\n                \"kind\": \"scalar\",\n                \"name\": \"number\"\n              }\n            ]\n          },\n          \"admin\": {\n            \"kind\": \"scalar\",\n            \"name\": \"boolean\"\n          }\n        }\n      }\n    },\n    \"pageSize\": {\n      \"kind\": \"scalar\",\n      \"name\": \"number\"\n    },\n    \"total\": {\n      \"kind\": \"scalar\",\n      \"name\": \"number\"\n    },\n    \"nextPage\": {\n      \"kind\": \"scalar\",\n      \"name\": \"string\"\n    },\n  }\n} Object with\n  'results' of\n    Array of\n      Object with\n        'name' of\n          string,\n        'score' of\n          string or\n          number,\n        'admin' of\n          boolean,\n  'pageSize' of\n    number,\n  'total' of\n    number,\n  'nextPage' of\n    string\n```\n\n## Sampling\n\nThis library defaults to checking up to only 5000 elements at any\nlevel which allows the inferrence to scale to very large datasets. It\nwill pick up to N elements randomly with the object to sample. To\ndisable this, pass `null`, `undefined`, or `false` as the second\nargument to `shape`. For example `shape(data, false)`.\n\nHowever, turning off sampling will eventually wreck your stack as you\npass bigger objects to `shape`.\n\n## Users\n\n* [DataStation](https://github.com/multiprocessio/datastation)\n\n## License\n\nApache-2.0, see [./LICENSE.md](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiprocessio%2Fshape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultiprocessio%2Fshape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiprocessio%2Fshape/lists"}