regstr v0.5.5
regStr module
introduction
regStr is a node.js module definining
The handler to JSON.stringify objects with RegExp properties and then JSON.parse json string resulted back.
usage in codes
var h = require('./regstr').regStr;
// or
h = require('regstr').regStr;Suppose the `o is a variable of some entity containing RegExp elements.
option 1
var jsonStr, clone, oj;
jsonStr = JSON.stringify(h.streger(o));
clone = h.reger(JSON.parse(jsonStr));
// Or
h.streger(o);
jsonStr = JSON.stringify(o);
oj = JSON.parse(jsonStr);
clone = h.reger(oj);option 2
var replacer = h.replacer.bind(h);
var reviver = h.reviver.bind(h);
jsonStr = JSON.stringify(o, replacer);
clone = JSON.parse(jsonStr, reviver);How
To download, to install and begin to use the package
go to the root of your project where you want to add regstr as dependent node.js module. Let's your project root dir is
someDisk:\some-path-to\your-proj-dir. I will denote it as~/your-proj-dir/`You need to have node.js and npm have been installed on your pc.
The explanaions following presume Windows Command Prompt environement.
source
The package Source repository front page
Install, Test, Usage
- Open cmd Command Prompt Shell
Ctl+R cmd {Enter}
- Go to the root directory of your package. Make it as the current one. This may be just new empty directory named as has been mentioned earlier. Download and install the module locally using npm package manager
cd /d ~\your-proj-dir
npm i regstrAfter the completion of all npm-node staff you could note some new staff in your dir:
- the subdirectory
node_moduleshas been created in~\your-proj-dir\dir with subfolderregstror if your project allready had any stuff this subfolder has been added to yournode_modulesfolder :
~\your-proj-dir
|-- node_modules
|-- regstr
|-- ...- To check the correctness of downloading an installation go to the appropriates regstr subpackage directories and run test commands:
at first to theuncycledir
cd .\node_modules\regstr\
npm run testSee the test output 5. Return to you package root folder and check if the package is accessible
cd ..\..\in ~\your-proj-dir\ directory as current one. Type
node
require.resolve('regstr')Look for the output being something like this:
diskLetter:\\etc\\..\\your-proj-dir\\node_modules\\regstr\\regstr.js
Exit from node.js REPL using command .exit and in Command Prompt type
npm run testIf you would have seen everything is as described then in any place of your .js files inside your project directory you could have access to regstr using the command
/* @type {Object} */
var r = require('regstr').regStr; // ! in .regStr S - uppercase
// or alternatively
var rr = require('./node_modules\regstr\regstr.js').regStr;Of course let or const could be used for assignement.
Explanation and details
The package has it's own explanation of usage, algorithm's details and is commented in details in script files. To get explanation in command propmt go into appropiate root folder of the package and run any of cmd commands
npm run explain
npm run explain-ciph
npm run explain-deciphYou are welcome!
Vladimir Uralov
v.url.node@gmail.com