Sha256: 7037d72df914dee18000fe88335805eaa03f9c63e9dfd09757a224739fe7f9de

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

// Koala - Formatter - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
/*global Koala*/
/**
 * Initialize with formatter function.
 */

Koala.Formatter = function(fn) {
  if (typeof fn !== 'function') throw new TypeError('Formatter requires a function');
  this.fn = fn;
};

/**
 * Render _str_ using the given _lexer_.
 *
 * @param  {Lexer} lexer
 * @param  {string} str
 * @return {string}
 * @api public
 */

Koala.Formatter.prototype.render = function(lexer, str) {
  var self = this;
  if (typeof lexer.scan !== 'function') throw new TypeError('Formatter#render() requires a lexer to be passed');
  return lexer.scan(str).map(function(token){
    return self.fn.call(self, token[0], token[1]);
  }).join('');
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sc-docs-0.0.3 vendor/jsdoc/app/plugins/smartdown/koala/formatter.js