Skip to content

Commit

Permalink
Turn into module, use justin
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jan 30, 2023
1 parent 496bfe3 commit f910e68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 47 deletions.
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* @module prepr
*/

var paren = require('parenthesis');
var balanced = require('balanced-match');
var extend = require('object-assign');
var escaper = require('escaper');
var ee = require('expression-eval');
var stripComments = require('strip-json-comments')
import paren from 'parenthesis';
import balanced from 'balanced-match';
import extend from 'object-assign';
import escaper from 'escaper';
import createFn from 'subscript/justin.js';
import stripComments from 'strip-json-comments';


/**
Expand Down Expand Up @@ -313,8 +313,8 @@ function preprocess (what, how) {
expr = stripComments(process(expr));

try {
var expr = ee.parse(expr);
result = ee.eval(expr, macros);
var evaluate = createFn(expr);
result = evaluate(expr, macros);
} catch (e) {
result = false;
}
Expand All @@ -341,4 +341,4 @@ function preprocess (what, how) {
}


module.exports = preprocess;
export default preprocess;
43 changes: 12 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.2.5",
"description": "Preprocess string in C/GLSL-preprocessor fashion",
"main": "index.js",
"type": "module",
"scripts": {
"test": "node test.js",
"test:browser": "budo test.js"
Expand Down Expand Up @@ -36,9 +37,9 @@
"dependencies": {
"balanced-match": "^2.0.0",
"escaper": "^2.5.3",
"expression-eval": "^5.0.0",
"object-assign": "^4.1.1",
"parenthesis": "^3.1.8",
"strip-json-comments": "^3.1.1"
"strip-json-comments": "^3.1.1",
"subscript": "^7.3.1"
}
}
9 changes: 4 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var test = require('tape');
var prepr = require('./');
var clean = require('cln');
var assert = require('assert');
import test from 'tape';
import prepr from './index.js';
import clean from 'cln';
import assert from 'assert';

test('Object macros', function (t) {
t.equal(clean(prepr(`
Expand Down Expand Up @@ -573,7 +573,6 @@ test('Real use-case', function (t) {


test('Too many comments', function (t) {
var escaper = require('escaper')
var src = `
/* a */
// b
Expand Down

0 comments on commit f910e68

Please sign in to comment.