Socket
Socket
Sign inDemoInstall

gulp-self-execute

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-self-execute

Wraps a JavaScript file in a self-executing anonymous function


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

gulp-self-execute

NPM version License Build Status Coverage Status Dependency Status

DEPRECATED: This package is no longer maintained

A Gulp plugin that wraps the contents of a JavaScript file with a self-executing anonymous function.

Install

Install via npm:

npm install --save-dev gulp-self-execute

Example

Suppose we want to wrap this code:

/* some masterpiece */

We run it through the plugin:

var gulp = require('gulp');
var selfExecute = require('gulp-self-execute');

gulp.task('self-execute', function() {
    return gulp.src('path/to/our/masterpiece.js')
        .pipe(selfExecute({
            'window', 'window',
            'jQuery': '$'
        }))
        .pipe(gulp.dest('some/excellent/directory'));
});

And we get this:

(function(window, $, undefined) {

/* some masterpiece */

}(window, jQuery));

API

selfExecute([options])
  • options (optional) Array | Object | null - Specifies the arguments to be passed to the function and their corresponding parameter names.

If options is a plain Object, its keys will be the arguments to be passed to the function and its values the corresponding parameter names.

selfExecute({
    'arg1': 'param1',
    'arg2': 'param2'
});

// Becomes:

(function(param1, param2, undefined) {
/* code */
}(arg1, arg2));

If options is an Array, each element will identify both an argument to be passed in and a parameter of the same name:

selfExecute([
    'thing1',
    'thing2'
]);

// Becomes:

(function(thing1, thing2, undefined) {
/* code */
}(thing1, thing2));

If options is null, no arguments or parameters will be defined.

selfExecute(null);

// Becomes:

(function(undefined) {
/* code */
}());

If options is undefined, our arguments/parameters will default to 'window' and 'document'.

selfExecute();

// Becomes:

(function(window, document, undefined) {
/* code */
}(window, document));

License

Copyright © 2015 Akim McMath. Licensed under the MIT License.

Keywords

FAQs

Package last updated on 14 Feb 2016

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