Skip to content

A simple npm package that predicts data types for comma-separated values, including JSON objects, and validates URLs, phone numbers, email addresses, and geolocation data within string values.

License

Notifications You must be signed in to change notification settings

melihbirim/predict-data-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Predict Data Types

A simple npm package that predicts data types for comma-separated values, including JSON objects, and validates URLs, phone numbers, email addresses, and geolocation data within string values.

Installation

npm install predict-data-types

Supported data types

  • boolean
  • string
  • number (decimal and integers are mapped to a number) // TODO improvement for specific data type
  • email
  • phone number
  • url
  • array (recursive check)
  • object

Usage

const predictDataTypes = require('predict-data-types');

const text = 'John, 123 Main St, [email protected], 555-555-5555, {"name": "John", "age": 30}, http://example.com';

const types = predictDataTypes(text);

console.log(types);

{
  'John': 'string',
  '123 Main St': 'string',
  '[email protected]': 'email',
  '555-555-5555': 'phone',
  '{"name": "John", "age": 30}': 'object',
  'http://example.com': 'url'
}

About

A simple npm package that predicts data types for comma-separated values, including JSON objects, and validates URLs, phone numbers, email addresses, and geolocation data within string values.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published