
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
fruitmachine-media
Advanced tools
FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries
FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries. If asychronous logic is needed to be run within a teardown or setup callback, return a promise.
var fm = require('fruitmachine');
fm.define({
name: 'passionfruit',
template: function() {
// Normal fruitmachine template method
},
helpers: [
require('fruitmachine-media')
],
media: {
'(max-width: 699px), (max-height: 699px)': 'small',
'(min-width: 700px) and (min-height: 700px)': 'large'
},
states: {
small: {
setup: function(options) {
// Run small setup logic
},
teardown: function(options) {
// Run small teardown logic
}
},
large: {
setup: function(options) {
// Run large setup logic
// If asychronous logic needs to be run:-
//
// var promise = new Promise();
// doAsyncStuff(function() {
// promise.resolve();
// });
// return promise;
},
teardown: function(options) {
// Run large teardown logic
}
}
}
});
Copyright (c) 2014 The Financial Times Limited Licensed under the MIT license.
All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.
FAQs
FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries
The npm package fruitmachine-media receives a total of 484 weekly downloads. As such, fruitmachine-media popularity was classified as not popular.
We found that fruitmachine-media demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.