🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

inline-code

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

inline-code

A library to help you inline code in JavaScript

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

inline-code

A library to help you inline code in JavaScript

Build Status Dependency Status NPM version

Installation

npm install inline-code

Usage

input.js

var d = document;
exports.element = document.createElement('div');
exports.otherElement = d.createElement('div');
exports.first = require('foo').mastermind('first value', 'second value');
var foo = require('foo');
exports.second = foo.mastermind('first value', 'second value');
exports.arr = foo.arrayify('a0', 'b1', 'c2', 'd3');
exports.max = max(10, 5);

build.js

fs.writeFileSync(__dirname + '/output.js', replace(fs.readFileSync(__dirname + '/input.js', 'utf8'), {
  globals: {
    document: {
      createElement: function (args) {
        if (args.length === 1 && args[0].TYPE === 'String') {
          return '"<' + args[0].value + '>"';
        } else {
          return '("<" + $args[0] + ">")';
        }
      }
    },
    max: function (args) {
      return 'Math.max($args)';
    }
  },
  requires: {
    foo: {
      mastermind: function (args) {
        return '$args[0] + "." + $args[1]';
      },
      arrayify: function (args) {
        return '[$args, "end"]';
      }
    }
  }
}));

output.js

"use strict";

exports.element = "<div>";

exports.otherElement = "<div>";

exports.first = "first value" + "." + "second value";

exports.second = "first value" + "." + "second value";

exports.arr = [ "a0", "b1", "c2", "d3", "end" ];

exports.max = Math.max(10, 5);

License

MIT

FAQs

Package last updated on 07 Jun 2014

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