{"id":26277630,"url":"https://github.com/uber-web/type-analyzer","last_synced_at":"2025-05-06T22:24:07.596Z","repository":{"id":24183094,"uuid":"100536461","full_name":"uber-web/type-analyzer","owner":"uber-web","description":null,"archived":false,"fork":false,"pushed_at":"2023-05-23T21:05:48.000Z","size":343,"stargazers_count":37,"open_issues_count":14,"forks_count":13,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-16T08:37:48.585Z","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/uber-web.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-16T22:05:41.000Z","updated_at":"2024-07-01T21:37:39.000Z","dependencies_parsed_at":"2024-06-18T15:15:40.477Z","dependency_job_id":"a54ee11f-2f1b-4e73-9c13-e5bb52b53a47","html_url":"https://github.com/uber-web/type-analyzer","commit_stats":{"total_commits":54,"total_committers":9,"mean_commits":6.0,"dds":0.7222222222222222,"last_synced_commit":"617c783384143a403e80e50f934a306ec4b8da0c"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-web%2Ftype-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-web%2Ftype-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-web%2Ftype-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-web%2Ftype-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uber-web","download_url":"https://codeload.github.com/uber-web/type-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252777594,"owners_count":21802618,"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":"2025-03-14T12:18:23.558Z","updated_at":"2025-05-06T22:24:07.536Z","avatar_url":"https://github.com/uber-web.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# type-analyzer\n\nInfer data types from CSV columns.\n\n## Overview\n\nThis package provides a single interface for generating the datatype for a given\nrow-column formatted dataset. We support the following datatypes:\n\n* **DATE**\n* **TIME**\n* **DATETIME**\n* **NUMBER**\n* **INT**\n* **FLOAT**\n* **CURRENCY**\n* **PERCENT**\n* **STRING**\n* **ARRAY**\n* **OBJECT**\n* **ZIPCODE**\n* **BOOLEAN**\n* **GEOMETRY**\n* **GEOMETRY_FROM_STRING**\n* **PAIR_GEOMETRY_FROM_STRING**\n* **NONE**\n\n## Installation\n\n    npm install type-analyzer\n\n## Usage\n\n### `Analyzer.computeColMeta(data, rules, options)` (Function)\n\n**Parameters**\n\n-  `data` **Array**  _required_ An array of row object\n-  `rules` **Array**  _optional_ An array of custom regex rules\n-  `options` **Object**  _optional_ Option object\n-  `options.ignoreDataTypes` **Array**  _optional_ Data types to ignore\n\n```js\nvar Analyzer = require('type-analyzer').Analyzer;\nvar data = [\n    {\n        \"ST_AsText\": \"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))\",\n        \"name\": \"san_francisco\",\n        \"lat\": \"37.7749295\",\n        \"lng\": \"-122.4194155\",\n        \"launch_date\": \"2010-06-05\",\n        \"added_at\": \"2010-06-05 12:00\"\n    },\n    {\n        \"ST_AsText\": \"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))\",\n        \"name\": \"paris\",\n        \"lat\": \"48.856666\",\n        \"lng\": \"2.3509871\",\n        \"launch_date\": \"2011-12-04\",\n        \"added_at\": \"2010-06-05 12:00\"\n    },\n]\nvar colMeta = Analyzer.computeColMeta(data);\n```\n- **`rules`**\n\nYou can pass in an array of custom rules. For example. if you want to ensure that a column full of ids represented as numbers is identified as a column of strings. Rules can be matched with either exact `name` of the column, or `regex` used to match names. Note: Analyzer prefers rules using name over regex since better performance.\n\n```js\nvar Analyzer = require('type-analyzer').Analyzer;\n\nvar colMeta = Analyzer.computeColMeta(data, [{name: 'id', dataType: 'STRING'}]);\n// or\nvar colMeta = Analyzer.computeColMeta(data, [{regex: /id/, dataType: 'STRING'}]);\n```\n\n- **`options.ignoreDataTypes`**\n\nYou can also pass in `ignoreDataTypes` to ignore certain types. This will improve your type checking performance.\n\n```js\nvar DATA_TYPES = require('type-analyzer').DATA_TYPES;\n\nvar colMeta = Analyzer.computeColMeta(arr, [], {ignoredDataTypes: DATA_TYPES.CURRENCY})[0].type,\n```\n\nAnd it will short cut around the usual analysis system and give\nyou back the column formatted as you'd expect.\n\n### `DATA_TYPES`\n\nYou can import all availale types as a constant.\n\n\n## Update\nBreaking changes with v1.0.0: Regex has moved into src, but can more easily be\naccessed from the module.exports from the root. As part of a larger clean up\nmany extraneous util files were removed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-web%2Ftype-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuber-web%2Ftype-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-web%2Ftype-analyzer/lists"}