New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

phantom-storm

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phantom-storm

Snapshot your code

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

Phantom storm Build Status

Installation

$ npm install phantom-storm --save

Example

Take a snapshot of your awesome code. Using Node v7+ you can run the example with node --harmony-async-await file.js

const fs = require('fs');
const phantomStorm = require('phantom-storm');

(async function(){
  const editor = await phantomStorm.init()

  editor.write('function greet(name) {return `Hello ${name}`}')
  const data = await editor.toBase64()

  fs.writeFile('greet.png', data, 'base64', err => {
    if (err) {
      console.log(err);
    }
    console.log('Done!', 'greet.png')
  });

  editor.close()
}())

NOTE

Module works only Node v7+ with flag: node --harmony-async-await your_file.js

Node.js v7.6+ now officially supports async functions without using the --harmony flag

editor object API

To create a new instance of editor use phantomStorm.init([options]) which returns a Promise which should resolve with a editor object.

phantomStorm.init().then( editor => /* ... */);

editor options

Options of editor may set in init([options]) method phantomStorm. Default options is: { language: 'js', theme: 'zenburn' }.

editor.setOptions(options)

Also options may changes after create instanse of editor like this: editor.setOptions({/* some options */}). For example:

editor.setOptions({ language: 'xml' });

Avaliable 150+ languages and 70+ theme.

See languages and theme demo

editor.listLanguages()

Returns list of avaliable languages.

editor.write(code)

Writes code in your editor.

phantomStorm.init().then( editor => editor.write('Your awesome code'));

editor.clear()

Clears editor

editor.write('Your awesome code');
editor.clear();

editor.toBase64()

Snapshots your js code with hightlight, and returns a Promise which should resolve with a base64 string.

phantomStorm.init().then( async (editor) => {
  editor.write('Your awesome code');
  const base64 = await editor.toBase64();
});

editor.toImage(filename, format='png', quality='100')

Snapshots your js code with hightlight and save image. Supported formats: pdf, png, jpeg, bmp, ppm. Quality: An integer between 0 and 100.

phantomStorm.init().then( async (editor) => {
  editor.write('function greet(name) {return `Hello ${name}`}');
  await editor.toImage('code.png')
});

editor.close()

Closes instance of editor. If you want to end work with editor just shut down it.

Keywords

shanpshot

FAQs

Package last updated on 22 Mar 2017

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