pc__replace_string_in_js

This is plugin for nmp-package "Post-Compression". He`s searching and replaces long string on short string, in the JS code.

Usage no npm install needed!

<script type="module">
  import pcReplaceStringInJs from 'https://cdn.skypack.dev/pc__replace_string_in_js';
</script>

README

Replace string in JS

This is plugin for nmp-package "Post-Compression".
He`s searching and replaces long string on short string, in the JS code.

An example of using:

var replaceStringInJS = require("pc__replace_string_in_js");

gulp.src("./*.js")
        replaceStringInJS()
    ], shortNames));

Where:

  • shortNames - an object of type JSON with rules replace the long words to short words.

An example of using with parameters: gulp.src("./*.js") replaceStringInJS({ type: "events_in_js", prefix: "addEvent(", postfix: ")", }) ], shortNames));

An example of the JSON object "shortNames":

{
    "string_in_js": {              // the name of the group names
        "someLongStringA": "a",    // long string: short string
        "someLongStringB": "b"
    }
}

An example of JS code before:

...someObject.addEvent("someLongStringA", function() {...
...someObject.triggerEvent("someLongStringB")...

An example of JS code after:

...someObject.addEvent("a", function() {...
...someObject.triggerEvent("b")...