char-props
Utility for looking up line and column of a character at a given index and vice versa.
Getting Started
Install the module with: npm install charProps
Documentation
// charProps is a function which invokes the Indexer constructor // Indexer JSDoc/** * Indexer constructor (takes index and performs pre-emptive caching) * @constructor * @param */ // Indexer.lineAt JSDoc/** * Get the line of the character at a certain index * @param * @param * @param * TODO: The following still have to be built/implemented * @param * @param * @returns */ // Indexer.columnAt JSDoc/** * Get the column of the character at a certain index * @param * @returns */ // Indexer.indexAt JSDoc/** * Get the index of the character at a line and column * @param * @param * @param * @returns */ // Indexer.charAt JSDoc/** * Get the character at a line and column * @param * @param * @param * @returns */
Examples
Initial load
var charProps = jquerySrc = fs; // Load jQuery into charPropsvar jqueryProps = ;
lineAt usage
// Look up line of character at index 42jqueryProps;
columnAt usage
// Look up column of character at index 88jqueryProps;
indexAt usage
// Look up the index of a character at line 9000, column 1jqueryProps;
charAt usage
// Get the character at line 20, column 20jqueryProps;
lineAt advanced usage
// Look up line of character at index 9001 with a minimum line of 99jqueryProps;
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code via grunt and test via vows.
License
Copyright (c) 2012 Todd Wolfson Licensed under the MIT license.