indefinite
Advanced tools
Comparing version
(function() { | ||
var isNode = (typeof module !== 'undefined' && this.module !== module); | ||
var indefinite = function (noun) { | ||
return (/[aeiou]/.test(noun.charAt(0).toLowerCase()) ? 'an ' : 'a ') + noun; | ||
var indefinite = function (noun, capitalize) { | ||
var phrase = (/[aeiou]/.test(noun.charAt(0).toLowerCase()) ? 'an ' : 'a ') + noun; | ||
if (capitalize) { | ||
return phrase.charAt(0).toUpperCase() + phrase.slice(1); | ||
} else { | ||
return phrase; | ||
} | ||
}; | ||
@@ -7,0 +12,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(){var e="undefined"!=typeof module&&this.module!==module,o=function(e){return(/[aeiou]/.test(e.charAt(0).toLowerCase())?"an ":"a ")+e};e?module.exports=o:window.indefinite=o}(); | ||
!function(){var e="undefined"!=typeof module&&this.module!==module,o=function(e,o){var t=(/[aeiou]/.test(e.charAt(0).toLowerCase())?"an ":"a ")+e;return o?t.charAt(0).toUpperCase()+t.slice(1):t};e?module.exports=o:window.indefinite=o}(); |
@@ -5,3 +5,3 @@ var gulp = require('gulp'); | ||
gulp.task('codeclimate', ['test'], function(cb) { | ||
gulp.task('codeclimate', function() { | ||
if (process.version.indexOf('v4') > -1) { | ||
@@ -8,0 +8,0 @@ gulp.src('coverage/lcov.info', { read: false }) |
@@ -6,3 +6,3 @@ var gulp = require('gulp'); | ||
gulp.task('cover', ['clean:coverage'], function() { | ||
gulp.task('cover', ['clean:coverage', 'instrument'], function() { | ||
return gulp.src(config.tests, { read: false }) | ||
@@ -9,0 +9,0 @@ .pipe(mocha({ |
var gulp = require('gulp'); | ||
require('file-manifest').generate('./gulp', ['**/*.js', '!config.js']); | ||
gulp.task('test', ['instrument', 'cover']); | ||
var sequence = require('gulp-sequence'); | ||
require('file-manifest').generate('./gulp', ['**/*.js', '!config.js', '!karma.conf.js']); | ||
gulp.task('travis', sequence(['lint', 'cover', 'phantom'], 'codeclimate')); | ||
gulp.task('test', ['cover', 'browser']); | ||
gulp.task('default', ['lint', 'test']); | ||
gulp.task('dist', ['uglify']); | ||
gulp.task('ci', ['lint', 'codeclimate']); | ||
gulp.task('build', sequence('clean:dist', ['copy', 'uglify'])); |
(function() { | ||
var isNode = (typeof module !== 'undefined' && this.module !== module); | ||
var indefinite = function (noun) { | ||
return (/[aeiou]/.test(noun.charAt(0).toLowerCase()) ? 'an ' : 'a ') + noun; | ||
var indefinite = function (noun, capitalize) { | ||
var phrase = (/[aeiou]/.test(noun.charAt(0).toLowerCase()) ? 'an ' : 'a ') + noun; | ||
if (capitalize) { | ||
return phrase.charAt(0).toUpperCase() + phrase.slice(1); | ||
} else { | ||
return phrase; | ||
} | ||
}; | ||
@@ -7,0 +12,0 @@ |
{ | ||
"name": "indefinite", | ||
"description": "Prefix a noun with an indefinite article - a or an - based on whether it begins with a vowel", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "lib/indefinite.js", | ||
@@ -42,8 +42,17 @@ "scripts": { | ||
"gulp-rename": "^1.2.2", | ||
"gulp-sequence": "^0.4.1", | ||
"gulp-uglify": "^1.4.2", | ||
"jshint-stylish": "^2.0.1", | ||
"karma": "^0.13.14", | ||
"karma-chrome-launcher": "^0.2.1", | ||
"karma-coffee-preprocessor": "^0.3.0", | ||
"karma-firefox-launcher": "^0.1.6", | ||
"karma-mocha": "^0.2.0", | ||
"karma-mocha-reporter": "^1.1.1", | ||
"karma-phantomjs-launcher": "^0.2.1", | ||
"mocha": "^2.3.3", | ||
"mocha-given": "^0.1.3", | ||
"phantomjs": "^1.9.18", | ||
"should": "^7.1.1" | ||
} | ||
} |
@@ -22,2 +22,6 @@ [](https://travis-ci.org/tandrewnichols/indefinite) [](https://npmjs.org/package/indefinite) [](https://npmjs.org/package/indefinite) [](https://codeclimate.com/github/tandrewnichols/indefinite) [](https://codeclimate.com/github/tandrewnichols/indefinite) [](https://david-dm.org/tandrewnichols/indefinite)  | ||
console.log(a('banana')); // "a banana" | ||
// You can also capitalize the article by passing "true" as the second argument | ||
console.log(a('apple', true)); // 'An apple' | ||
console.log(a('banana', true)); // 'A banana' | ||
``` | ||
@@ -24,0 +28,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16396
29.47%27
12.5%220
61.76%35
12.9%24
60%