Socket
Socket
Sign inDemoInstall

append-transform

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

append-transform - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

15

index.js

@@ -8,3 +8,4 @@ 'use strict';

function appendTransform(transform, ext, extensions) {
var key = __dirname + count;
// Generate a unique key for this transform
var key = __dirname + count; // eslint-disable-line
count++;

@@ -17,3 +18,3 @@ ext = ext || '.js';

var descriptor = Object.getOwnPropertyDescriptor(extensions, ext);
var descriptor = Object.getOwnPropertyDescriptor(extensions, ext) || {value: undefined, configurable: true};

@@ -28,2 +29,3 @@ if (

if (descriptor.get) {
// wrap a previous append-transform install and pass through to the getter/setter pair it created
forwardGet = function () {

@@ -46,4 +48,12 @@ return descriptor.get();

function hookWasUndefined(module, filename) {
throw new Error('Can not load ' + filename + '. No require extension has been installed for ' + ext + ' files');
}
function wrapCustomHook(hook) {
if (hook === undefined) {
return hookWasUndefined;
}
return function (module, filename) {
// We wrap every added extension, but we only apply the transform to the one on top of the stack
if (!module[key]) {

@@ -75,2 +85,3 @@ module[key] = true;

} else {
// we have already scene this hook, and it is being reverted (proxyquire, etc) - don't wrap again.
hooks.splice(restoreIndex + 1, hooks.length);

@@ -77,0 +88,0 @@ forwardSet(hook);

2

package.json
{
"name": "append-transform",
"version": "0.2.2",
"version": "0.3.0",
"description": "Install a transform to `require.extensions` that always runs last, even if additional extensions are added later.",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc