Skip to content

Commit

Permalink
Remove unnecessary new Function wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
c-harding committed Jun 24, 2019
1 parent 8928ac5 commit 2645317
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/defaultPlugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import registerPlugin from './registerPlugin';
import functionFromString from './functionFromString';
import Stage from './Stage';
import CJSSError from './CJSSError';

Expand Down Expand Up @@ -28,7 +27,7 @@ registerPlugin('json', body => () => {
registerPlugin('html', (body) => {
const code = `return \`${body}\``;
try {
const render = functionFromString(code, ['data', 'yield']);
const render = new Function('data', 'yield', code);

return (element, data) => {
try {
Expand Down Expand Up @@ -77,7 +76,7 @@ const assignBody = (element, body) => {

const javascriptPlugin = (isBody, jsTransformer = x => x) => (js) => {
try {
const f = functionFromString(jsTransformer(js), isBody ? ['data', 'yield'] : ['data']);
const f = new Function('data', ...isBody ? 'yield' : undefined, jsTransformer(js));

return (element, data) => {
try {
Expand Down
22 changes: 0 additions & 22 deletions src/functionFromString.js

This file was deleted.

0 comments on commit 2645317

Please sign in to comment.