Readable regular expressions
See demo.js
for an example of the ways ReadEx can improve an ugly,
unreadable regular expression.
- Composability. ReadExes should be able to combine other ReadExes so indiviual component patterns can be named and reused.
- Free Formatting. ReadExes should only pay attention to whitespace when it is explicitly quoted and called out. All other whitespace should be ignored to allow free formatting by the programmer.
- Verbosity. ReadExes should use full names rather than obscure symbols and single letters to denote patterns and operations. Comments should be allowed.
Here is a quick example of how this module can be used in other modules. The TypeScript Module Resolution Logic makes it quite easy. The file src/index.ts
is a barrel that re-exports selected exports from other files. The package.json file contains main
attribute that points to the generated lib/index.js
file and typings
attribute that points to the generated lib/index.d.ts
file.
If you are planning to have code in multiple files (which is quite natural for a NodeJS module) that users can import, make sure you update
src/index.ts
file appropriately.
Now assuming you have published this amazing module to npm with the name my-amazing-lib
, and installed it in the module in which you need it -
- To use the
Greeter
class in a TypeScript file -
import { Greeter } from "my-amazing-lib";
const greeter = new Greeter("World!");
greeter.greet();
- To use the
Greeter
class in a JavaScript file -
const Greeter = require('my-amazing-lib').Greeter;
const greeter = new Greeter('World!');
greeter.greet();
- Sign in to travis and activate the build for your project.
- Sign in to coveralls and activate the build for your project.
- Replace {{github-user-name}}/{{github-app-name}} with your repo details like: "ospatil/generator-node-typescript".
This project was initialized with generator-node-typescript