Comparing version 1.1.0 to 1.1.1
@@ -5,4 +5,3 @@ /* | ||
var figlet = require('../../lib/node-figlet.js'), | ||
jQuery = require('jquery'); | ||
var figlet = require('../../lib/node-figlet.js'); | ||
@@ -9,0 +8,0 @@ /* |
@@ -571,2 +571,5 @@ /* | ||
} | ||
if (opts.printDirection === 1) { | ||
txt = txt.split('').reverse().join(''); | ||
} | ||
len=txt.length; | ||
@@ -686,19 +689,2 @@ for (charIndex = 0; charIndex < len; charIndex++) { | ||
}; | ||
me.textSync = function(txt, options) { | ||
var fontName = ''; | ||
// Validate inputs | ||
txt = txt + ''; | ||
if (typeof options === 'string') { | ||
fontName = options; | ||
options = {}; | ||
} else { | ||
options = options || {}; | ||
fontName = options.font || figDefaults.font; | ||
} | ||
var fontOpts = _reworkFontOpts(me.loadFontSync(fontName), options); | ||
return generateText(fontName, fontOpts, txt); | ||
}; | ||
me.text = function(txt, options, next) { | ||
@@ -738,2 +724,27 @@ var fontName = ''; | ||
/* | ||
Synchronous version of figlet.text. | ||
Accepts the same parameters. | ||
*/ | ||
me.textSync = function(txt, options) { | ||
var fontName = ''; | ||
// Validate inputs | ||
txt = txt + ''; | ||
if (typeof options === 'string') { | ||
fontName = options; | ||
options = {}; | ||
} else { | ||
options = options || {}; | ||
fontName = options.font || figDefaults.font; | ||
} | ||
var fontOpts = _reworkFontOpts(me.loadFontSync(fontName), options); | ||
return generateText(fontName, fontOpts, txt); | ||
}; | ||
/* | ||
takes assigned options and merges them with the default options from the choosen font | ||
*/ | ||
function _reworkFontOpts(fontOpts, options) { | ||
@@ -760,2 +771,3 @@ var myOpts = JSON.parse(JSON.stringify(fontOpts)), // make a copy because we may edit this (see below) | ||
} | ||
myOpts.printDirection = (typeof options.printDirection !== 'undefined') ? options.printDirection : fontOpts.printDirection; | ||
myOpts.showHardBlanks = options.showHardBlanks || false; | ||
@@ -762,0 +774,0 @@ |
@@ -23,5 +23,7 @@ /* | ||
fontData = fontData + ''; | ||
fontData = figlet.parseFont(name, fontData); | ||
next(null, fontData); | ||
try { | ||
next(null, figlet.parseFont(name, fontData)); | ||
} catch(error) { | ||
next(error); | ||
} | ||
}); | ||
@@ -28,0 +30,0 @@ }; |
{ | ||
"name": "figlet", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Creates ASCII Art from text. A full implementation of the FIGfont spec.", | ||
@@ -18,6 +18,3 @@ "keywords": ["figlet", "ascii", "art", "banner", "ansi"], | ||
}, | ||
"licenses": [ { | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} ], | ||
"license": "MIT", | ||
"main": "./lib/node-figlet.js", | ||
@@ -36,3 +33,3 @@ "dependencies": { | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
@@ -39,0 +36,0 @@ "engines": { |
@@ -10,2 +10,3 @@ ``` | ||
``` | ||
[![Build Status](https://travis-ci.org/patorjk/figlet.js.svg)](https://travis-ci.org/patorjk/figlet.js) | ||
@@ -19,3 +20,3 @@ This project aims to fully implement the FIGfont spec in JavaScript. It works in the browser and with Node.js. You can see it in action here: http://patorjk.com/software/taag/ (the figlet.js file was written to power that application) | ||
``` | ||
```sh | ||
npm install figlet | ||
@@ -26,3 +27,3 @@ ``` | ||
``` | ||
```js | ||
var figlet = require('figlet'); | ||
@@ -65,3 +66,3 @@ | ||
``` | ||
```js | ||
figlet.text('Boo!', { | ||
@@ -104,4 +105,4 @@ font: 'Ghost', | ||
``` | ||
console.log( figlet.textSync('Boo!', { | ||
```js | ||
console.log(figlet.textSync('Boo!', { | ||
font: 'Ghost', | ||
@@ -180,3 +181,3 @@ horizontalLayout: 'default', | ||
``` | ||
```js | ||
figlet.metadata('Standard', function(err, options, headerComment) { | ||
@@ -193,15 +194,7 @@ if (err) { | ||
### fontsSync | ||
### fonts | ||
The synchronous version of the fonts method | ||
``` | ||
console.log(figlet.fontsSync()); | ||
``` | ||
### fontsSync | ||
The fonts function allows you to get a list of all of the available fonts. Example usage: | ||
``` | ||
```js | ||
figlet.fonts(function(err, fonts) { | ||
@@ -217,2 +210,10 @@ if (err) { | ||
### fontsSync | ||
The synchronous version of the fonts method | ||
```js | ||
console.log(figlet.fontsSync()); | ||
``` | ||
Getting Started - The Browser | ||
@@ -225,3 +226,3 @@ ------------------------- | ||
``` | ||
```html | ||
<script type="text/javascript" src="jquery-1.7.2.min.js"></script> | ||
@@ -251,3 +252,3 @@ <script type="text/javascript" src="figlet.js"></script> | ||
```shell | ||
```sh | ||
npm install -g figlet-cli | ||
@@ -258,3 +259,3 @@ ``` | ||
```shell | ||
```sh | ||
figlet -f "Dancing Font" "Hi" | ||
@@ -261,0 +262,0 @@ ``` |
@@ -103,2 +103,17 @@ | ||
}, | ||
printDirection: function(test) { | ||
test.expect(1); | ||
figlet.text('pizzapie', { | ||
font: 'Dancing Font', | ||
horizontalLayout: 'full', | ||
printDirection: 1 | ||
}, function(err, actual) { | ||
var expected = grunt.file.read('test/expected/dancingFontReverse'); | ||
test.equal(actual, expected, 'Dancing Font with a reversed print direction.'); | ||
test.done(); | ||
}); | ||
}, | ||
/* | ||
@@ -105,0 +120,0 @@ This test ensures that all fonts will load without error |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3106701
309
1398
260