Skip to content

Commit

Permalink
Optimize code after merge of #398
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Mar 6, 2017
1 parent cd10945 commit ca3318b
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/index.js
Expand Up @@ -134,7 +134,6 @@ module.exports = function(source, inputSourceMap) {
delete options.metadataSubscribers;

this.cacheable();
const context = this;

if (cacheDirectory) {
const callback = this.async();
Expand All @@ -144,18 +143,18 @@ module.exports = function(source, inputSourceMap) {
source: source,
options: options,
transform: transpile,
}, function(err, result) {
if (err) { return callback(err); }
metadataSubscribers.forEach(function (s) {
passMetadata(s, context, result.metadata);
});
return callback(null, result.code, result.map);
}, (err, { code, map, metadata } = {}) => {
if (err) return callback(err);

metadataSubscribers.forEach((s) => passMetadata(s, this, metadata));

return callback(null, code, map);
});
}

const result = transpile(source, options);
metadataSubscribers.forEach(function (s) {
passMetadata(s, context, result.metadata);
});
this.callback(null, result.code, result.map);
const { code, map, metadata } = transpile(source, options);

metadataSubscribers.forEach((s) => passMetadata(s, this, metadata));

this.callback(null, code, map);
};

0 comments on commit ca3318b

Please sign in to comment.