Skip to content

Default parameters is missing #7

Open

Description

@azu

espurify ignore .default property by default.
Is it expected bahavior?

"use strict";
const esprima = require("esprima");
const escodegen = require("escodegen");
const espurify = require('espurify');

var code = `function addPrefix(text, prefix = "Default:") {
                return prefix + text;
            }`;
const jsAst = esprima.parse(code);
const modifiedAst = espurify(jsAst);
console.log(escodegen.generate(modifiedAst));
/*
 function addPrefix(text, prefix) { // <= no default parameter
     return prefix + text;
 }
 */

Activity

  1. twada commented on Jul 29, 2016

    @twada
    Member

    espurify is intended to be compliant with The ESTree Spec.
    defaults properly of Function(Declaration|Expression) is not in the spec, so it is discarded by default.

    If you want to purify non-complient tree, please use espurify.cloneWithWhitelist function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions