Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

javascript-from-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

javascript-from-string

A javascript package to extract valid javascript from a string

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Javascript From String

A simple package to convert valid Javascript found in a string to Javascript

npm version npm downloads

Getting Started

Step 1

Install the dependency

npm i --save javascript-from-string

Or if you prefer yarn

yarn add javascript-from-string

Step 2

Import it in your script

const jsConvert = require('javascript-from-string');

Step 3

Call the Conversion promise

const jsString = '{ prop: "value" }';

jsConvert.convert(jsString)
    .then(jsObject => {
        console.log(jsObject);
    })
    .catch(err => {
        console.log(err);
    })

Or if you prefer to use Async Await

const jsString = '{ prop: "value" }';

async function getObject(jsString) {
    const jsObject = await jsConvert.convert(jsString);
    return jsObject;
}

getObject(jsString).then(obj => console.log(obj));

Keywords

FAQs

Package last updated on 10 May 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc