Text Node
Base class for minimal text nodes.
Installation
$ npm install minimal-text-class --save
Usage
To create a new text node,
var Text = ;var text = ;
The text
instance has the following methods...
text.content( [content] )
This method is a setter/getter. If no content
is provided, returns the text content
. To set the text content
textcontent 'beep' ;
Note: setting new content
will replace any existing content.
text.append( content )
This is a convenience method for appending new content
to existing content.
// Inconvenient...textcontent textcontent+'boop' ;// Convenient...text;
text.toString()
Serializes the node as a string
; i.e., returns the text content
.
text;
This method provides a consistent interface with minimal elements.
Examples
var text = ;textcontent 'beep' ;for var i = 0; i < 10; i++text;console;// Returns 'beep!!!!!!!!!!'
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
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.
Test Coverage
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
License
Copyright
Copyright © 2014. Athan Reines.