Base class for minimal text nodes.
$ npm install minimal-text-class --save
To create a new text node,
var Text = require( 'minimal-text-class' );
var text = new Text();
The text
instance has the following methods...
This method is a setter/getter. If no content
is provided, returns the text content
. To set the text content
text.content( 'beep' );
Note: setting new content
will replace any existing content.
This is a convenience method for appending new content
to existing content.
// Inconvenient...
text.content( text.content()+'boop' );
// Convenient...
text.append( 'boop' );
Serializes the node as a string
; i.e., returns the text content
.
text.toString();
This method provides a consistent interface with minimal elements.
var text = new Text();
text.content( 'beep' );
for ( var i = 0; i < 10; i++ ) {
text.append( '!' );
}
console.log( text.toString() );
// Returns 'beep!!!!!!!!!!'
To run the example code from the top-level application directory,
$ node ./examples/index.js
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.html
Copyright © 2014. Athan Reines.