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

p5-global2instance

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p5-global2instance

Convert p5js code/snippet from global mode to instance mode

latest
Source
npmnpm
Version
0.9.0
Version published
Weekly downloads
10
900%
Maintainers
1
Weekly downloads
 
Created
Source

p5-global2instance

Convert p5js code/snippet from global to instance mode

Install

npm install p5-global2instance

Usage

There are 2 away to use this script.

CLI

p5-global2instance sourceCode.js

This will produce file sourceCode.p5.js. For more details use --help

node test.js --help

  Usage: test [options] [file]


  Options:

    -o, --output [file]  Save output file to [file]
    -p, --print          Print result to stdout
    -h, --help           output usage information

Import as module

Take this example code

const p5Convert = require('p5-global2instance')

const sourceCode = `
var current;
var previous;

function setup () {
  createCanvas(720, 400);
};

function draw () {
  background(0);
};
`

let output = p5Convert(sourceCode)
console.log(output)

It will output

import p5 from 'p5';
export default function (sketch) {
  var current;
  var previous;

  sketch.setup = function () {
    sketch.createCanvas(720, 400);
  };

  sketch.draw = function () {
    sketch.background(0);
  };
}

Options

You can also pass esprima and escodegen options.

p5Convert(sourceCode, {
  esprima: {},
  escodegen: {}
})

FAQs

Package last updated on 18 Dec 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