Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function polyfillResponse({uaString, minify, query = {} }) {
const features = (query.features || '').split(',').filter(Boolean).reduce((res, x) => ({ ...res, [x]: { flags: ['gated'] }}), {})
const cache = !!query.cache
const polyfill = await getPolyfillString({ uaString, minify, features })
const headers = {
'Content-Type': 'application/javascript;charset=utf-8',
...cache && { 'Cache-Control': 'max-age=31536000' }, // 365 days
}
return {
status: 200,
headers,
data: { polyfill, uaString }
}
}
gulp.task('browserify', function(gulpTaskCompleteCallback) {
var isInitialized = false;
var polyfillServiceList = polyfillService.getAllPolyfills();
var packageJson = JSON.parse(fs.readFileSync('package.json'));
var version = packageJson.version;
var name = packageJson.name;
var polyfillsCache = {};
mkdirp.sync('./dist/' + version + '/');
mkdirp.sync('./demo/lib/' + name + '/' + version + '/');
mkdirp.sync('./test/lib/' + name + '/dev/');
// function inspect() {
// return highland.pipeline(function(stream) {
// return stream.map(function(file) {
// if (file.isNull()) {
// return file;
// }
// return file;
if (!locale) {
locale = getLocale(request.headers["accept-language"], locales);
}
var features = request.query.features + ',Intl.~locale.' + locale;
var flags = request.query.flags ? request.query.flags.split(',') : [];
var polyfills = PolyfillSet.fromQueryParam(features || 'default', flags);
var params = {
features: polyfills.get(),
minify: true,
unknown: 'polyfill'
};
params.uaString = request.plugins.scooter.source;
polyfillio.getPolyfillString(params).then(function(bundleString) {
reply(bundleString).type('application/javascript; charset=utf-8').vary('User-Agent');
});
},
config: {
return new Promise((resolve) => {
polyfillio.getPolyfillString(params).then(function(bundleString) {
resolve(h.response(bundleString).type('application/javascript; charset=utf-8').vary('User-Agent'));
});
});
},