🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

predict-data-types

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
20
150%
Maintainers
1
Weekly downloads
 
Created
Source

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, john@example.com, 555-555-5555, {"name": "John", "age": 30}, http://example.com';

const types = predictDataTypes(text);

console.log(types);

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

Keywords

predict

FAQs

Package last updated on 09 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts