How to use module - 10 common examples

To help you get started, we’ve selected a few module examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imba / imba / lib / register.js View on Github external
Module.prototype.load = function (filename){
			// console.log "getting to Module#load",filename
			this.filename = filename;
			this.paths = Module._nodeModulePaths(path.dirname(filename));
			var ext = findExtension(filename);
			Module._extensions[ext](this,filename);
			return this.loaded = true;
		};
	} else if(require.registerExtension) {
github sebmarkbage / link.js / Source / Node / link.js View on Github external
function preloadImports(parsedModule, parent){
	for (var i = 0, l = parsedModule.imports.length; i < l; i++){
		var path = parsedModule.imports[i];
		if (!(path in aliases)){
			if (path in testObject)
				path = path + '.js'; // Resolve Node cache bug
			parsedModule.imports[i] = path = Module._resolveFilename(path, parent);
		}
		if (Path.extname(aliases[path] || path) == '.js' && !Object.prototype.hasOwnProperty.call(require.cache, path)){
			var mod = new Module(path, parent);
			mod.filename = path;
			preload(path, mod);
		}
	}
}
github oroinc / platform / src / Oro / Bundle / UIBundle / Resources / public / js / app / views / flash-message-view.js View on Github external
define(function(require) {
    'use strict';

    var FlashMessageView;
    var BaseView = require('oroui/js/app/views/base/view');
    var messenger = require('oroui/js/messenger');
    var _ = require('underscore');
    var config = require('module').config();

    config = _.extend({
        template: require('tpl!oroui/templates/message-item.html') // default admin template
    }, config);

    FlashMessageView = BaseView.extend({
        autoRender: true,

        template: config.temlpate,

        optionNames: BaseView.prototype.optionNames.concat(['container', 'messages', 'initializeMessenger']),

        initializeMessenger: false,

        /**
         * @inheritDoc
github coveraje / coveraje / lib / helper / index.js View on Github external
function compile(content, mod, filename, dirname) {
                    var Script = process.binding('evals').NodeScript;
                    var runInThisContext = Script.runInThisContext;

                    // create wrapper function
                    //
                    var wrapper = Module.wrap(content);

                    var compiledWrapper = runInThisContext(wrapper, filename, true);
                    var args = [mod.exports, requireSubst(mod), mod, filename, dirname];

                    return compiledWrapper.apply(mod.exports, args);
                }
github uber-archive / nanny / _worker.js View on Github external
function handleStart(modulePath, givenPulse) {

    if (started) {
        throw new Error('Assertion failed: worker received a second start message over its IPC channel');
    }
    started = true;

    // Start periodic health reports.
    pulse = givenPulse;
    if (pulse) {
        tick();
    }

    // Start running the worker module.
    Module._load(modulePath, null, true);
}
github ruowo / stdx / scripts / pnode / main.js View on Github external
var Module = require('module')
let entrypoint = process.argv[2]
if (entrypoint) {
  if (entrypoint === '-m') {
    console.log(process.versions.modules)
    process.exit(0)
  } else if (entrypoint === '-v') {
    console.log(process.versions.node)
    process.exit(0)
  }
  Module._load(entrypoint, null, true)
  process._tickCallback() 
}
github pluginjs / pluginjs / tools / cli / scripts / utils / require-rc-file.js View on Github external
function requireFromString(code) {
  const paths = Module._nodeModulePaths(path.dirname(''))
  const parent = module.parent
  const m = new Module('', parent)
  m.filename = ''
  m.paths = paths

  m._compile(code, '')
  return m.exports
}
github yosbelms / cor / src / loader / node.js View on Github external
cor.Program.prototype.getExports = function(parent) {
    var mod, js = this.toJs();

    mod = new Module(this.filename, parent);

    mod.filename = this.filename;
    mod.paths    = Module._nodeModulePaths(nodePath.dirname(this.filename));
    mod.src      = js.src;
    mod.loaded   = true;
    mod._contextLoad = true;
    mod._compile(js.src, this.filename);

    return mod.exports || {};
}
github axmor / typecs / src / com.axmor.eclipse.typescript.core / lib / bridge / ts_1.0 / ets_io.js View on Github external
run: function (source, fileName) {
      log.debug('io.run:' + fileName);
      require.main.fileName = fileName;
      require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName)));
      require.main._compile(source, fileName);
    },
github imba / imba / register.js View on Github external
Module.prototype.load = function (filename){
		this.filename = filename;
		this.paths = Module._nodeModulePaths(path.dirname(filename));
		var ext = findExtension(filename);
		Module._extensions[ext](this,filename);
		return this.loaded = true;
	};

module

Generate the minimal skeleton/boilerplate for a new Node.js module.

MIT
Latest version published 8 years ago

Package Health Score

41 / 100
Full package analysis