New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ifdef-loader

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ifdef-loader - npm Package Compare versions

Comparing version 0.0.13 to 1.0.0

10

ifdef-loader.js

@@ -14,4 +14,9 @@ "use strict";

}
var tripleSlashFlag = "ifdef-triple-slash";
var tripleSlash = data[tripleSlashFlag];
if (tripleSlash) {
delete data[tripleSlashFlag];
}
try {
source = preprocessor_1.parse(source, data, verbose);
source = preprocessor_1.parse(source, data, verbose, tripleSlash);
this.callback(null, source, map);

@@ -21,5 +26,4 @@ }

var errorMessage = "ifdef-loader error: " + err;
console.log(errorMessage);
this.callback(errorMessage);
this.callback(new Error(errorMessage));
}
};

@@ -19,14 +19,17 @@ import path = require('path');

try
{
source = parse(source, data, verbose);
const tripleSlashFlag = "ifdef-triple-slash";
const tripleSlash = data[tripleSlashFlag];
if(tripleSlash) {
delete data[tripleSlashFlag];
}
try {
source = parse(source, data, verbose, tripleSlash);
this.callback(null, source, map);
}
catch(err)
{
catch(err) {
const errorMessage = `ifdef-loader error: ${err}`;
console.log(errorMessage);
this.callback(errorMessage);
this.callback(new Error(errorMessage));
}
};
{
"name": "ifdef-loader",
"version": "0.0.13",
"version": "1.0.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "ifdef-loader.js",

"use strict";
function parse(source, defs, verbose) {
var triple_slash = true;
function parse(source, defs, verbose, tripleSlash) {
triple_slash = tripleSlash || true;
var lines = source.split('\n');

@@ -32,3 +34,3 @@ for (var n = 0;;) {

function match_if(line) {
var re = /^[\s]*\/\/([\s]*)#(if)([\s\S]+)$/g;
var re = triple_slash ? /^[\s]*\/\/\/([\s]*)#(if)([\s\S]+)$/g : /^[\s]*\/\/([\s]*)#(if)([\s\S]+)$/g;
var match = re.exec(line);

@@ -45,3 +47,3 @@ if (match) {

function match_endif(line) {
var re = /^[\s]*\/\/([\s]*)#(endif)[\s]*$/g;
var re = triple_slash ? /^[\s]*\/\/\/([\s]*)#(endif)[\s]*$/g : /^[\s]*\/\/([\s]*)#(endif)[\s]*$/g;
var match = re.exec(line);

@@ -48,0 +50,0 @@ if (match)

@@ -7,3 +7,7 @@ interface IStart {

export function parse(source, defs, verbose?: boolean): string {
let triple_slash = true;
export function parse(source, defs, verbose?: boolean, tripleSlash?: boolean): string {
triple_slash = tripleSlash || true;
const lines = source.split('\n');

@@ -43,3 +47,3 @@

function match_if(line: string): IStart|undefined {
const re = /^[\s]*\/\/([\s]*)#(if)([\s\S]+)$/g;
const re = triple_slash ? /^[\s]*\/\/\/([\s]*)#(if)([\s\S]+)$/g : /^[\s]*\/\/([\s]*)#(if)([\s\S]+)$/g;
const match = re.exec(line);

@@ -57,3 +61,3 @@ if(match) {

function match_endif(line: string): boolean {
const re = /^[\s]*\/\/([\s]*)#(endif)[\s]*$/g;
const re = triple_slash ? /^[\s]*\/\/\/([\s]*)#(endif)[\s]*$/g : /^[\s]*\/\/([\s]*)#(endif)[\s]*$/g;
const match = re.exec(line);

@@ -60,0 +64,0 @@ if(match) return true;

@@ -6,3 +6,3 @@ # ifdef-loader

Conditional compilation directives are written inside `//` doubleslash comment so
Conditional compilation directives are written inside `///` triple slash comment so
that they don't effect normal JavaScript or TypeScript parsing.

@@ -12,5 +12,5 @@

```js
// #if DEBUG
/// #if DEBUG
console.log("there's a bug!");
// #endif
/// #endif
```

@@ -21,5 +21,5 @@ The `DEBUG` or any other variable can be specified when configuring the Webpack loader (see below).

```js
// #if PRODUCTION && version.charAt(0)=='X'
/// #if PRODUCTION && version.charAt(0)=='X'
console.log("Ho!");
// #endif
/// #endif
```

@@ -32,10 +32,10 @@

```js
// #if PRODUCTION
// #if OS=="android"
/// #if PRODUCTION
/// #if OS=="android"
android_code();
// #endif
// #if OS=="ios"
/// #endif
/// #if OS=="ios"
ios_code();
// #endif
// #endif
/// #endif
/// #endif
```

@@ -62,3 +62,4 @@

version: 3,
"ifdef-verbose": true // add this for verbose output
"ifdef-verbose": true // add this for verbose output
"ifdef-triple-slash": false // add this to use double slash comment instead of default triple slash
};

@@ -75,8 +76,8 @@

```ts
// #if DEBUG
/// #if DEBUG
/* code to be included if DEBUG is defined */
// #if version <2
/// #if version <2
/* code to be included if DEBUG is defined and version < 2*/
// #endif
// #endif
/// #endif
/// #endif
```

@@ -92,1 +93,5 @@

## Changes
- v1.0.0 changed to triple slash comment syntax. Double slash syntax
deprecated and available by turning off the `ifdef-triple-slash` option.
var a=1;
// #if version > 4
/// #if version > 4
loadVersion4();
// #if OS === "android"
/// #if OS === "android"
android_Init_In_Version_4();
// #endif
// #endif
/// #endif
/// #endif
a=a+1;
var b=1;
// #if version < 4
/// #if version < 4
loadVersion2();
// #if OS === "ios"
/// #if OS === "ios"
IOS_Init_In_Version_2();
// #endif
// #endif
/// #endif
/// #endif
b=a+1;
var a=1;
//////////////////
///////////////////
///////////////
////////////////////////////
/////////////////////////////
/////////////////////////////////
//////////////
/////////
///////////////
//////////
a=a+1;
var b=1;
//////////////////
///////////////////
loadVersion2();
////////////////////////
/////////////////////////
/////////////////////////////
//////////////
/////////
///////////////
//////////
b=a+1;
var a=1;
//////////////////
///////////////////
///////////////
////////////////////////////
/////////////////////////////
/////////////////////////////////
//////////////
/////////
///////////////
//////////
a=a+1;
var b=1;
//////////////////
///////////////////
loadVersion2();
////////////////////////
/////////////////////////
/////////////////////////////
//////////////
/////////
///////////////
//////////
b=a+1;
var a=1;
// #if DEBUG
/// #if DEBUG
debug("hello");
// #endif
/// #endif
var b=2;
// #if OS === "android"
/// #if OS === "android"
androidInit();
// #endif
/// #endif
var c=3;
// #if version > 4
/// #if version > 4
loadVersion4();
// #endif
/// #endif
var a=1;
////////////
/////////////
debug("hello");
/////////
//////////
var b=2;
///////////////////////
////////////////////////
androidInit();
/////////
//////////
var c=3;
//////////////////
///////////////////
///////////////
/////////
//////////
var a=1;
////////////
/////////////
debug("hello");
/////////
//////////
var b=2;
///////////////////////
////////////////////////
androidInit();
/////////
//////////
var c=3;
//////////////////
///////////////////
///////////////
/////////
//////////
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