Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
gulp-self-execute
Advanced tools
A Gulp plugin that wraps the contents of a JavaScript file with a self-executing anonymous function.
Install via npm:
npm install --save-dev gulp-self-execute
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));
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));
Copyright © 2015 Akim McMath. Licensed under the MIT License.
FAQs
Wraps a JavaScript file in a self-executing anonymous function
The npm package gulp-self-execute receives a total of 2 weekly downloads. As such, gulp-self-execute popularity was classified as not popular.
We found that gulp-self-execute demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.