Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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 9 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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.