{"id":22650657,"url":"https://github.com/data7expressions/typ3s","last_synced_at":"2025-07-14T16:05:42.406Z","repository":{"id":153280207,"uuid":"628776452","full_name":"data7expressions/typ3s","owner":"data7expressions","description":"json types, type , types","archived":false,"fork":false,"pushed_at":"2024-03-20T12:12:45.000Z","size":875,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-21T12:48:44.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/data7expressions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-04-17T00:39:37.000Z","updated_at":"2024-04-14T22:28:19.671Z","dependencies_parsed_at":"2024-01-18T05:55:20.089Z","dependency_job_id":"34e850e4-a6cd-424f-ab88-3113a8f3a73e","html_url":"https://github.com/data7expressions/typ3s","commit_stats":null,"previous_names":["expr-solver/typ3s","flaviolionelrita/typ3s","data7expressions/typ3s"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data7expressions%2Ftyp3s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data7expressions%2Ftyp3s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data7expressions%2Ftyp3s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data7expressions%2Ftyp3s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/data7expressions","download_url":"https://codeload.github.com/data7expressions/typ3s/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246151587,"owners_count":20731634,"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-12-09T08:36:26.790Z","updated_at":"2025-03-29T07:22:18.648Z","avatar_url":"https://github.com/data7expressions.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typ3s\n\n[![language typescript](https://img.shields.io/badge/language-typescript-blue)](https://www.npmjs.com/package/lambdaorm)\n[![npm version](https://img.shields.io/badge/npm-10.2.5-green)](https://www.npmjs.com/package/typ3s)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Github CI](https://img.shields.io/badge/Github-CI-red.svg)](https://github.com/lambda-orm/lambdaorm/actions?query=workflow%3A%22publish%22)\n\nThe objective of this library is to obtain the type of an object, array, function, etc. \\\nAlso be able to obtain information about the cardinality of the data.\n\n## Primitive\n\n- string\n- integer\n- decimal\n- number\n- boolean\n- date\n- dateTime\n- time\n- any\n- void\n\n## Array / Tuples\n\n[]\n\n## Object\n\n{}\n\n## Function\n\n()\n\n## Modifiers\n\n|Modifier           |description             |\n|:------------------|:-----------------------|\n| !\t\t\t\t\t\t\t\t\t| Nullable\t\t\t\t\t\t\t |\n| ?\t\t\t\t\t\t\t\t\t| Undefinable\t\t\t\t\t\t |\n| #\t\t\t\t\t\t\t\t\t| Unique\t\t\t\t\t\t\t   |\n| ~\t\t\t\t\t\t\t\t\t| Async\t\t\t\t\t\t\t\t\t |\n\n## Examples\n\n|type                           \t|description                        \t\t\t\t\t\t\t\t\t\t\t\t|\n|:--------------------------------|:----------------------------------------------------------|\n| [string]                      \t| array of string                   \t\t\t\t\t\t\t\t\t\t\t\t|\n| [string, integer]             \t| tuple with string and integer properties\t\t\t\t\t\t\t\t\t|\n| {name:string, nro:integer}    \t| object with string and integer \tproperties\t\t\t\t\t\t\t\t|\n| [{name:string, today:date}]   \t| array of object                         \t\t\t\t\t\t\t\t\t|\n| (\u003eany)                       \t\t| function without params and return value\t\t\t\t\t\t\t\t\t|\n| (list:[integer]\u003einteger)     \t\t| function with array integer as params and return integer\t|\n| (today:date,nro:?integer\u003edate)\t| function with undefinable integer param \t\t\t\t\t\t\t\t\t|\n| {name:string,nro:?integer}    \t| object of properties string and undefinable integer\t\t\t\t|\n| {name:string,nro:!integer}    \t| object of properties string and nullable integer \t\t\t\t\t|\n| ([integer]\u003e~integer) \t\t\t\t\t\t| function with return async of integer\t\t\t\t\t\t\t\t\t\t\t|\n\n## Methods\n\n| method        |description                        \t\t\t\t\t\t|\n|:--------------|:----------------------------------------------|\n| type       \t\t| get the type   \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| stringify     | converts the type to a string\t\t\t\t\t\t\t\t\t|\n| parse    \t\t\t| converts the string to type\t\t\t\t\t\t\t\t\t\t|\n| serialize    \t| serialize type\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| deserialized\t| deserialize type\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| validate\t\t\t| validate data with type\t\t\t\t\t\t\t\t\t\t\t\t|\n\n## Type method\n\nThe type method allows us to obtain the type of an object, array, function, etc. \\\nIdentifying primitive types, arrays, objects, functions, etc. \\\nIn the case of Array, it will evaluate the type of the array elements. \\\nAnd in the case of Object it will evaluate the type of the object's properties. \\\n\nThe type method has as its second optional parameter \"options\" which can receive the following properties:\n\n| property  |description                      |\n|:----------|:--------------------------------|\n| info      | get the info of the type        |\n| describes | get the description of the type |\n| enums     | get the enums of the type       |\n\n**In case of setting info:**\n\n```ts\nconst type = Type.type(data, { info: true })\n```\n\nThe following information will be added to the type:\n\n| property      |description                        |\n|:--------------|:----------------------------------|\n| indefinite    | number of undefined values        |\n| nullables     | number of null values             |\n| repeated      | number of repeated values         |\n| distinctCount | number of distinct values         |\n| count         | number of total values            |\n| repeatRate    | percentage of repeated values     |\n| nullable      | if type is null                   |\n| undefinable   | if type is undefined              |\n| unique        | if the type is unique             |\n\n**In the case of setting, describe:**\n\n```ts\nconst type = Type.type(data, { describe: true })\n```\n\nThe following information will be added to the type:\n\n| property  |description              |\n|:----------|:------------------------|\n| percent10 | repeating value 10%     |\n| percent25 | repeating value 25%     |\n| percent50 | value that repeats 50%  |\n| percent75 | value that repeats 75%  |\n| percent90 | value that repeats 90%  |\n| max       | maximum value           |\n| min       | minimum value           |\n| maxLen    | maximum length          |\n| minLen    | minimum length          |\n| sum       | sum of values           |\n| mean      | average                 |\n| std       | standard deviation      |\n\n**In the case of setting enums:**\n\n```ts\nconst type = Type.type(data, { enums: true })\n```\n\n**The following information will be added to the type:**\n\n| property  |description      |\n|:----------|:----------------|\n| enums     | enum values     |\n\n## stringify method\n\nThe stringify method allows us to convert the type to a string.\n\n```ts\nconst type = Type.type(data)\nconst stringified = Type.stringify(type)\n```\n\n## Parse method\n\nThe parse method allows us to convert a string to a type.\n\n```ts\nconst type = Type.type(data)\nconst stringified = Type.stringify(type)\nconst type2 = Type.parse(stringified)\n```\n\n## Serialize method\n\nThe serialize method allows us to serialize a type.\n\n```ts\nconst type = Type.type(data)\nconst serialized = Type.serialize(type)\n```\n\n## Deserialize method\n\nThe deserialize method allows us to deserialize a type.\n\n```ts\nconst type = Type.type(data)\nconst serialized = Type.serialize(type)\nconst deserialized = Type.deserialize(serialized)\n```\n\n## Validate method\n\nThe validate method allows us to validate data with a type.\n\n```ts\nlet [isValid, message] = Type.validate(data, '[{name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string}]')\nif (!isValid) {\n\tconsole.log(message)\n} else {\n\tconsole.log('Valid!')\n}\n```\n\n## Example\n\nThis example shows how you can obtain the type of an array of objects, convert it to a string, parse it, serialize it, and deserialize it.\n\n```ts\nimport { Type } from 'typ3s'\nconst data = [\n\t{\n\t\tname: 'Spain',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Spanish', 'Catalan', 'Galician', 'Basque'],\n\t\tphoneCode: 34,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United Kingdom',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 44,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Italy',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Italian'],\n\t\tphoneCode: 39,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'France',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['French'],\n\t\tphoneCode: 33,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Argentina',\n\t\tregion: { name: 'South America', code: 'SA', description: 'South America' },\n\t\tlanguages: ['Spanish'],\n\t\tphoneCode: 54,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Germany',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['German'],\n\t\tphoneCode: 49,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Portugal',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Portuguese'],\n\t\tphoneCode: 351,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United States',\n\t\tregion: { name: 'North America', code: 'NA', description: 'North America' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 1,\n\t\treligion: 'Christianity'\n\t}\n]\nconst type = Type.type(data)\nconst stringified = Type.stringify(type)\nconst type2 = Type.parse(stringified)\nconst serialized = Type.serialize(type2, 2)\nconst deserialized = Type.deserialize(serialized)\nconst serialize2 = Type.serialize(deserialized)\nconsole.log(stringified)\nconsole.log(serialized)\nconsole.log(serialize2)\n```\n\n**stringify result:**\n\n```javascript\n[{name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string}]\n```\n\n**serialized result:**\n\n```json\n{\n  \"primitive\": \"list\",\n  \"list\": {\n    \"items\": {\n      \"primitive\": \"obj\",\n      \"obj\": {\n        \"properties\": [\n          {\n            \"name\": \"name\",\n            \"type\": {\n              \"primitive\": \"string\"\n            }\n          },\n          {\n            \"name\": \"region\",\n            \"type\": {\n              \"primitive\": \"obj\",\n              \"obj\": {\n                \"properties\": [\n                  {\n                    \"name\": \"name\",\n                    \"type\": {\n                      \"primitive\": \"string\"\n                    }\n                  },\n                  {\n                    \"name\": \"code\",\n                    \"type\": {\n                      \"primitive\": \"string\"\n                    }\n                  },\n                  {\n                    \"name\": \"description\",\n                    \"type\": {\n                      \"primitive\": \"string\"\n                    }\n                  }\n                ]\n              }\n            }\n          },\n          {\n            \"name\": \"languages\",\n            \"type\": {\n              \"primitive\": \"list\",\n              \"list\": {\n                \"items\": {\n                  \"primitive\": \"string\"\n                }\n              }\n            }\n          },\n          {\n            \"name\": \"phoneCode\",\n            \"type\": {\n              \"primitive\": \"integer\"\n            }\n          },\n          {\n            \"name\": \"religion\",\n            \"type\": {\n              \"primitive\": \"string\"\n            }\n          }\n        ]\n      }\n    }\n  }\n}\n```\n\n**serialized result 2:**\n\n```json\n{\"primitive\":\"list\",\"list\":{\"items\":{\"primitive\":\"obj\",\"obj\":{\"properties\":[{\"name\":\"name\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"region\",\"type\":{\"primitive\":\"obj\",\"obj\":{\"properties\":[{\"name\":\"name\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"code\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"description\",\"type\":{\"primitive\":\"string\"}}]}}},{\"name\":\"languages\",\"type\":{\"primitive\":\"list\",\"list\":{\"items\":{\"primitive\":\"string\"}}}},{\"name\":\"phoneCode\",\"type\":{\"primitive\":\"integer\"}},{\"name\":\"religion\",\"type\":{\"primitive\":\"string\"}}]}}}}\n```\n\n## Info example\n\nThis example shows how you can obtain the info of an array of objects. \\\nTo use the info method it is necessary to pass the info: true parameter in the type method.\n\n```ts\nimport { Type } from 'typ3s'\nconst data = [\n\t{\n\t\tname: 'Spain',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Spanish', 'Catalan', 'Galician', 'Basque'],\n\t\tphoneCode: 34,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United Kingdom',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 44,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Italy',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Italian'],\n\t\tphoneCode: 39,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'France',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['French'],\n\t\tphoneCode: 33,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Argentina',\n\t\tregion: { name: 'South America', code: 'SA', description: 'South America' },\n\t\tlanguages: ['Spanish'],\n\t\tphoneCode: 54,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Germany',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['German'],\n\t\tphoneCode: 49,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Portugal',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Portuguese'],\n\t\tphoneCode: 351,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United States',\n\t\tregion: { name: 'North America', code: 'NA', description: 'North America' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 1,\n\t\treligion: 'Christianity'\n\t}\n]\nconst type = Type.type(data, { info: true })\nconst stringified = Type.stringify(type)\nconst serialized = Type.serialize(type, 1)\nconsole.log(stringified)\nconsole.log(serialized)\n```\n\n**stringified:**\n\n```javascript\n[#{languages:[string],name:#string,phoneCode:#integer,region:{code:string,description:string,name:string},religion:string}]\n```\n\n**serialized:**\n\n```json\n{\n \"primitive\": \"list\",\n \"list\": {\n  \"items\": {\n   \"primitive\": \"obj\",\n   \"obj\": {\n    \"properties\": [\n     {\n      \"name\": \"languages\",\n      \"type\": {\n       \"primitive\": \"list\",\n       \"list\": {\n        \"items\": {\n         \"primitive\": \"string\",\n         \"indefinite\": 0,\n         \"nullables\": 0,\n         \"repeated\": 2,\n         \"distinctCount\": 9,\n         \"count\": 11,\n         \"repeatRate\": 0.03636363636363636,\n         \"nullable\": false,\n         \"undefinable\": false,\n         \"unique\": false\n        }\n       },\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 2,\n       \"count\": 11,\n       \"repeatRate\": 0.03636363636363636,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false,\n       \"distinctCount\": 9\n      }\n     },\n     {\n      \"name\": \"name\",\n      \"type\": {\n       \"primitive\": \"string\",\n       \"onParentDistinctRepeated\": 0,\n       \"distinctCount\": 8,\n       \"onParentDistinctRepeatedRate\": 0,\n       \"onParentDistinctUnique\": true,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 0,\n       \"count\": 8,\n       \"repeatRate\": 0,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": true\n      }\n     },\n     {\n      \"name\": \"phoneCode\",\n      \"type\": {\n       \"primitive\": \"integer\",\n       \"onParentDistinctRepeated\": 0,\n       \"distinctCount\": 8,\n       \"onParentDistinctRepeatedRate\": 0,\n       \"onParentDistinctUnique\": true,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 0,\n       \"count\": 8,\n       \"repeatRate\": 0,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": true\n      }\n     },\n     {\n      \"name\": \"region\",\n      \"type\": {\n       \"primitive\": \"obj\",\n       \"obj\": {\n        \"properties\": [\n         {\n          \"name\": \"code\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false\n          }\n         },\n         {\n          \"name\": \"description\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false\n          }\n         },\n         {\n          \"name\": \"name\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false\n          }\n         }\n        ]\n       },\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 15,\n       \"distinctCount\": 3,\n       \"count\": 8,\n       \"repeatRate\": 0.5357142857142857,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false\n      }\n     },\n     {\n      \"name\": \"religion\",\n      \"type\": {\n       \"primitive\": \"string\",\n       \"onParentDistinctRepeated\": 13,\n       \"distinctCount\": 2,\n       \"onParentDistinctRepeatedRate\": 0.4642857142857143,\n       \"onParentDistinctUnique\": false,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 13,\n       \"count\": 8,\n       \"repeatRate\": 0.4642857142857143,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false\n      }\n     }\n    ]\n   },\n   \"repeated\": 0,\n   \"nullables\": 0,\n   \"indefinite\": 0,\n   \"distinctCount\": 8,\n   \"count\": 8,\n   \"repeatRate\": 0,\n   \"nullable\": false,\n   \"undefinable\": false,\n   \"unique\": true\n  }\n }\n}\n```\n\n## Describe example\n\nThis example shows how you can obtain the description of an array of objects. \\\nTo use the describe method it is necessary to pass the describe: true parameter in the type method.\n\n```ts\nimport { Type } from 'typ3s'\nconst data = [\n\t{\n\t\tname: 'Spain',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Spanish', 'Catalan', 'Galician', 'Basque'],\n\t\tphoneCode: 34,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United Kingdom',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 44,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Italy',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Italian'],\n\t\tphoneCode: 39,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'France',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['French'],\n\t\tphoneCode: 33,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Argentina',\n\t\tregion: { name: 'South America', code: 'SA', description: 'South America' },\n\t\tlanguages: ['Spanish'],\n\t\tphoneCode: 54,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Germany',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['German'],\n\t\tphoneCode: 49,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Portugal',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Portuguese'],\n\t\tphoneCode: 351,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United States',\n\t\tregion: { name: 'North America', code: 'NA', description: 'North America' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 1,\n\t\treligion: 'Christianity'\n\t}\n]\nconst type = Type.type(data, { describe: true })\nconst serialized = Type.serialize(type, 1)\nconsole.log(serialized)\n```\n\n**Result:**\n\n```json\n{\n \"primitive\": \"list\",\n \"list\": {\n  \"items\": {\n   \"primitive\": \"obj\",\n   \"obj\": {\n    \"properties\": [\n     {\n      \"name\": \"languages\",\n      \"type\": {\n       \"primitive\": \"list\",\n       \"list\": {\n        \"items\": {\n         \"primitive\": \"string\",\n         \"indefinite\": 0,\n         \"nullables\": 0,\n         \"repeated\": 2,\n         \"distinctCount\": 9,\n         \"count\": 11,\n         \"repeatRate\": 0.03636363636363636,\n         \"nullable\": false,\n         \"undefinable\": false,\n         \"unique\": false,\n         \"percent10\": \"Catalan\",\n         \"percent25\": \"Galician\",\n         \"percent50\": \"Italian\",\n         \"percent75\": \"German\",\n         \"percent90\": \"Portuguese\",\n         \"max\": \"Spanish\",\n         \"min\": \"Basque\",\n         \"maxLen\": 10,\n         \"minLen\": 6\n        }\n       },\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 2,\n       \"count\": 11,\n       \"repeatRate\": 0.03636363636363636,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false,\n       \"distinctCount\": 9\n      }\n     },\n     {\n      \"name\": \"name\",\n      \"type\": {\n       \"primitive\": \"string\",\n       \"onParentDistinctRepeated\": 0,\n       \"distinctCount\": 8,\n       \"onParentDistinctRepeatedRate\": 0,\n       \"onParentDistinctUnique\": true,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 0,\n       \"count\": 8,\n       \"repeatRate\": 0,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": true,\n       \"percent10\": \"Spain\",\n       \"percent25\": \"Italy\",\n       \"percent50\": \"Argentina\",\n       \"percent75\": \"Portugal\",\n       \"percent90\": \"United States\",\n       \"max\": \"United States\",\n       \"min\": \"Argentina\",\n       \"maxLen\": 14,\n       \"minLen\": 5\n      }\n     },\n     {\n      \"name\": \"phoneCode\",\n      \"type\": {\n       \"primitive\": \"integer\",\n       \"onParentDistinctRepeated\": 0,\n       \"distinctCount\": 8,\n       \"onParentDistinctRepeatedRate\": 0,\n       \"onParentDistinctUnique\": true,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 0,\n       \"count\": 8,\n       \"repeatRate\": 0,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": true,\n       \"percent10\": 1,\n       \"percent25\": 34,\n       \"percent50\": 44,\n       \"percent75\": 54,\n       \"percent90\": 351,\n       \"sum\": 605,\n       \"max\": 351,\n       \"min\": 1,\n       \"mean\": 75.625,\n       \"std\": 105.15932852105894\n      }\n     },\n     {\n      \"name\": \"region\",\n      \"type\": {\n       \"primitive\": \"obj\",\n       \"obj\": {\n        \"properties\": [\n         {\n          \"name\": \"code\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false,\n           \"percent10\": \"EU\",\n           \"percent25\": \"EU\",\n           \"percent50\": \"SA\",\n           \"percent75\": \"EU\",\n           \"percent90\": \"NA\",\n           \"max\": \"SA\",\n           \"min\": \"EU\",\n           \"maxLen\": 2,\n           \"minLen\": 2\n          }\n         },\n         {\n          \"name\": \"description\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false,\n           \"percent10\": \"European Union\",\n           \"percent25\": \"European Union\",\n           \"percent50\": \"South America\",\n           \"percent75\": \"European Union\",\n           \"percent90\": \"North America\",\n           \"max\": \"South America\",\n           \"min\": \"European Union\",\n           \"maxLen\": 14,\n           \"minLen\": 13\n          }\n         },\n         {\n          \"name\": \"name\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false,\n           \"percent10\": \"Europe\",\n           \"percent25\": \"Europe\",\n           \"percent50\": \"South America\",\n           \"percent75\": \"Europe\",\n           \"percent90\": \"North America\",\n           \"max\": \"South America\",\n           \"min\": \"Europe\",\n           \"maxLen\": 13,\n           \"minLen\": 6\n          }\n         }\n        ]\n       },\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 15,\n       \"distinctCount\": 3,\n       \"count\": 8,\n       \"repeatRate\": 0.5357142857142857,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false\n      }\n     },\n     {\n      \"name\": \"religion\",\n      \"type\": {\n       \"primitive\": \"string\",\n       \"onParentDistinctRepeated\": 13,\n       \"distinctCount\": 2,\n       \"onParentDistinctRepeatedRate\": 0.4642857142857143,\n       \"onParentDistinctUnique\": false,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 13,\n       \"count\": 8,\n       \"repeatRate\": 0.4642857142857143,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false,\n       \"percent10\": \"Roman Catholicism\",\n       \"percent25\": \"Roman Catholicism\",\n       \"percent50\": \"Roman Catholicism\",\n       \"percent75\": \"Roman Catholicism\",\n       \"percent90\": \"Christianity\",\n       \"max\": \"Roman Catholicism\",\n       \"min\": \"Christianity\",\n       \"maxLen\": 17,\n       \"minLen\": 12\n      }\n     }\n    ]\n   },\n   \"repeated\": 0,\n   \"nullables\": 0,\n   \"indefinite\": 0,\n   \"distinctCount\": 8,\n   \"count\": 8,\n   \"repeatRate\": 0,\n   \"nullable\": false,\n   \"undefinable\": false,\n   \"unique\": true\n  }\n }\n}\n```\n\n## Enums example\n\nThis example shows how you can obtain the enums of an array of objects. \\\nTo use the enums method it is necessary to pass the enums: true parameter in the type method.\n\n```ts\nimport { Type } from 'typ3s'\nconst data = [\n\t{\n\t\tname: 'Spain',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Spanish', 'Catalan', 'Galician', 'Basque'],\n\t\tphoneCode: 34,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United Kingdom',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 44,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Italy',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Italian'],\n\t\tphoneCode: 39,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'France',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['French'],\n\t\tphoneCode: 33,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Argentina',\n\t\tregion: { name: 'South America', code: 'SA', description: 'South America' },\n\t\tlanguages: ['Spanish'],\n\t\tphoneCode: 54,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'Germany',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['German'],\n\t\tphoneCode: 49,\n\t\treligion: 'Christianity'\n\t},\n\t{\n\t\tname: 'Portugal',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Portuguese'],\n\t\tphoneCode: 351,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United States',\n\t\tregion: { name: 'North America', code: 'NA', description: 'North America' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 1,\n\t\treligion: 'Christianity'\n\t}\n]\nconst type = Type.type(data, { enums: true })\nconst serialized = Type.serialize(type, 1)\nconsole.log(serialized)\n```\n\n**Enum Result:**\n\nIn the event that it detects a field that is repeated and there are few options, it is considered an enum. \\\nIn this case, detect that the religion field is repeated and there are only two options, so it is considered an enum. \\\nGiving information on the values and the number of times it is repeated.\n\n```json\n...\n{\n  \"name\": \"religion\",\n  \"type\": {\n    \"primitive\": \"string\",\n    \"onParentDistinctRepeated\": 13,\n    \"distinctCount\": 2,\n    \"onParentDistinctRepeatedRate\": 0.4642857142857143,\n    \"onParentDistinctUnique\": false,\n    \"indefinite\": 0,\n    \"nullables\": 0,\n    \"repeated\": 13,\n    \"count\": 8,\n    \"repeatRate\": 0.4642857142857143,\n    \"nullable\": false,\n    \"undefinable\": false,\n    \"unique\": false,\n    \"enums\": [\n    {\n      \"value\": \"Roman Catholicism\",\n      \"count\": 5\n    },\n    {\n      \"value\": \"Christianity\",\n      \"count\": 3\n    }\n    ]\n  }\n}\n...\n```\n\n**Complete Result:**\n\n```json\n{\n \"primitive\": \"list\",\n \"list\": {\n  \"items\": {\n   \"primitive\": \"obj\",\n   \"obj\": {\n    \"properties\": [\n     {\n      \"name\": \"languages\",\n      \"type\": {\n       \"primitive\": \"list\",\n       \"list\": {\n        \"items\": {\n         \"primitive\": \"string\",\n         \"indefinite\": 0,\n         \"nullables\": 0,\n         \"repeated\": 2,\n         \"distinctCount\": 9,\n         \"count\": 11,\n         \"repeatRate\": 0.03636363636363636,\n         \"nullable\": false,\n         \"undefinable\": false,\n         \"unique\": false\n        }\n       },\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 2,\n       \"count\": 11,\n       \"repeatRate\": 0.03636363636363636,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false,\n       \"distinctCount\": 9\n      }\n     },\n     {\n      \"name\": \"name\",\n      \"type\": {\n       \"primitive\": \"string\",\n       \"onParentDistinctRepeated\": 0,\n       \"distinctCount\": 8,\n       \"onParentDistinctRepeatedRate\": 0,\n       \"onParentDistinctUnique\": true,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 0,\n       \"count\": 8,\n       \"repeatRate\": 0,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": true\n      }\n     },\n     {\n      \"name\": \"phoneCode\",\n      \"type\": {\n       \"primitive\": \"integer\",\n       \"onParentDistinctRepeated\": 0,\n       \"distinctCount\": 8,\n       \"onParentDistinctRepeatedRate\": 0,\n       \"onParentDistinctUnique\": true,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 0,\n       \"count\": 8,\n       \"repeatRate\": 0,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": true\n      }\n     },\n     {\n      \"name\": \"region\",\n      \"type\": {\n       \"primitive\": \"obj\",\n       \"obj\": {\n        \"properties\": [\n         {\n          \"name\": \"code\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false\n          }\n         },\n         {\n          \"name\": \"description\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false\n          }\n         },\n         {\n          \"name\": \"name\",\n          \"type\": {\n           \"primitive\": \"string\",\n           \"onParentDistinctRepeated\": 0,\n           \"distinctCount\": 3,\n           \"onParentDistinctRepeatedRate\": 0,\n           \"onParentDistinctUnique\": true,\n           \"indefinite\": 0,\n           \"nullables\": 0,\n           \"repeated\": 15,\n           \"count\": 8,\n           \"repeatRate\": 0.5357142857142857,\n           \"nullable\": false,\n           \"undefinable\": false,\n           \"unique\": false\n          }\n         }\n        ]\n       },\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 15,\n       \"distinctCount\": 3,\n       \"count\": 8,\n       \"repeatRate\": 0.5357142857142857,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false\n      }\n     },\n     {\n      \"name\": \"religion\",\n      \"type\": {\n       \"primitive\": \"string\",\n       \"onParentDistinctRepeated\": 13,\n       \"distinctCount\": 2,\n       \"onParentDistinctRepeatedRate\": 0.4642857142857143,\n       \"onParentDistinctUnique\": false,\n       \"indefinite\": 0,\n       \"nullables\": 0,\n       \"repeated\": 13,\n       \"count\": 8,\n       \"repeatRate\": 0.4642857142857143,\n       \"nullable\": false,\n       \"undefinable\": false,\n       \"unique\": false,\n       \"enums\": [\n        {\n         \"value\": \"Roman Catholicism\",\n         \"count\": 5\n        },\n        {\n         \"value\": \"Christianity\",\n         \"count\": 3\n        }\n       ]\n      }\n     }\n    ]\n   },\n   \"repeated\": 0,\n   \"nullables\": 0,\n   \"indefinite\": 0,\n   \"distinctCount\": 8,\n   \"count\": 8,\n   \"repeatRate\": 0,\n   \"nullable\": false,\n   \"undefinable\": false,\n   \"unique\": true\n  }\n }\n}\n```\n\n## Validate example\n\nThis example shows how you can validate an object with a type.\n\n```ts\nimport { Type } from 'typ3s'\nconst data = [\n\t{\n\t\tname: 'Spain',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['Spanish', 'Catalan', 'Galician', 'Basque'],\n\t\tphoneCode: 34,\n\t\treligion: 'Roman Catholicism'\n\t},\n\t{\n\t\tname: 'United Kingdom',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tlanguages: ['English'],\n\t\tphoneCode: 44,\n\t\treligion: 'Christianity'\n\t}\n]\nconst withoutLanguages = [\n\t{\n\t\tname: 'Italy',\n\t\tregion: { name: 'Europe', code: 'EU', description: 'European Union' },\n\t\tphoneCode: 39,\n\t\treligion: 'Roman Catholicism'\n\t}\n]\nconst withoutRegionCode = [\n\t{\n\t\tname: 'France',\n\t\tregion: { name: 'Europe', description: 'European Union' },\n\t\tlanguages: ['French'],\n\t\tphoneCode: 33,\n\t\treligion: 'Roman Catholicism'\n\t}\n]\nconst incorrectPhoneCode = [\n\t{\n\t\tname: 'Argentina',\n\t\tregion: { name: 'South America', code: 'SA', description: 'South America' },\n\t\tlanguages: ['Spanish'],\n\t\tphoneCode: '54',\n\t\treligion: 'Roman Catholicism'\n\t}\n]\nconst type = Type.type(data)\nconst stringified = Type.stringify(type)\nlet [isValid, message] = Type.validate(data, type)\nif (!isValid) {\n\tconsole.log(message)\n} else {\n\tconsole.log('Valid!')\n}\n[isValid, message] = Type.validate(withoutLanguages, type)\nif (!isValid) {\n\tconsole.log(message)\n} else {\n\tconsole.log('Valid!')\n}\n[isValid, message] = Type.validate(withoutRegionCode, stringified)\nif (!isValid) {\n\tconsole.log(message)\n} else {\n\tconsole.log('Valid!')\n}\n[isValid, message] = Type.validate(incorrectPhoneCode, stringified)\nif (!isValid) {\n\tconsole.log(message)\n} else {\n\tconsole.log('Valid!')\n}\n```\n\n**Data Result:**\n\n```sh\nValid!\n```\n\n**WithoutLanguages Result:**\n\n```sh\n[{name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string}] item {name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string} property languages [string] value: undefined is not an array\n```\n\n**WithoutRegionCode Result:**\n\n```sh\n[{name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string}] item {name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string} property region {name:string,code:string,description:string} property code Value undefined is not a string\n```\n\n**IncorrectPhoneCode Result:**\n\n```sh\n[{name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string}] item {name:string,region:{name:string,code:string,description:string},languages:[string],phoneCode:integer,religion:string} property phoneCode Value 54 is not an integer\n```\n\n## Source documentation\n\n- Source documentation is available in [Source Code Documentation](https://github.com/data7expressions/typ3s/tree/main/doc/source)\n\n## Related projects\n\n- [json-light](https://www.npmjs.com/package/json-light)\n- [3xpr](https://www.npmjs.com/package/3xpr)\n- [jexp](https://www.npmjs.com/package/jexp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdata7expressions%2Ftyp3s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdata7expressions%2Ftyp3s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdata7expressions%2Ftyp3s/lists"}