indefinite
Advanced tools
| var gulp = require('gulp'); | ||
| var Server = require('karma').Server; | ||
| var path = require('path'); | ||
| gulp.task('browser', function(done) { | ||
| new Server({ | ||
| configFile: path.resolve(__dirname, '../karma.conf.js'), | ||
| singleRun: true | ||
| }, done).start(); | ||
| }); | ||
| gulp.task('phantom', function(done) { | ||
| new Server({ | ||
| configFile: path.resolve(__dirname, '../karma.conf.js'), | ||
| browsers: ['PhantomJS'], | ||
| singleRun: true | ||
| }, done).start(); | ||
| }); | ||
| gulp.task('ci', function(done) { | ||
| new Server({ | ||
| configFile: path.resolve(__dirname, '../karma.conf.js') | ||
| }, done).start(); | ||
| }); |
| // Karma configuration | ||
| // Generated on Fri Oct 23 2015 14:00:27 GMT-0400 (EDT) | ||
| module.exports = function(config) { | ||
| config.set({ | ||
| // base path that will be used to resolve all patterns (eg. files, exclude) | ||
| basePath: '', | ||
| // frameworks to use | ||
| // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
| frameworks: ['mocha'], | ||
| // list of files / patterns to load in the browser | ||
| files: [ | ||
| 'node_modules/mocha-given/browser/mocha-given.js', | ||
| 'node_modules/should/should.js', | ||
| 'dist/indefinite.js', | ||
| 'test/helpers/**/*.js', | ||
| 'test/**/*.coffee' | ||
| ], | ||
| // list of files to exclude | ||
| exclude: [ | ||
| ], | ||
| // preprocess matching files before serving them to the browser | ||
| // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
| preprocessors: { | ||
| '**/*.coffee': ['coffee'] | ||
| }, | ||
| // test results reporter to use | ||
| // possible values: 'dots', 'progress' | ||
| // available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
| reporters: ['mocha'], | ||
| // web server port | ||
| port: 9876, | ||
| // enable / disable colors in the output (reporters and logs) | ||
| colors: true, | ||
| // level of logging | ||
| // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
| logLevel: config.LOG_INFO, | ||
| // enable / disable watching file and executing tests whenever any file changes | ||
| autoWatch: true, | ||
| // start these browsers | ||
| // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
| browsers: ['Chrome', 'Firefox', 'PhantomJS'], | ||
| // Continuous Integration mode | ||
| // if true, Karma captures browsers, runs the tests and exits | ||
| singleRun: false, | ||
| // Concurrency level | ||
| // how many browser should be started simultanous | ||
| concurrency: Infinity | ||
| }) | ||
| } |
| window.require = function(path) { | ||
| return window.indefinite; | ||
| }; |
+1
-1
@@ -6,3 +6,3 @@ language: node_js | ||
| script: | ||
| - "gulp ci" | ||
| - "gulp travis" | ||
| node_js: | ||
@@ -9,0 +9,0 @@ - "0.10" |
| (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 }) |
+1
-1
@@ -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({ |
+5
-4
| 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 @@ |
+10
-1
| { | ||
| "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" | ||
| } | ||
| } |
+4
-0
@@ -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 @@ |
@@ -15,1 +15,8 @@ describe 'indefinite', -> | ||
| Then -> @subject('Banana').should.eql 'a Banana' | ||
| context 'capitalize the article when the noun has a vowel', -> | ||
| Then -> @subject('apple', true).should.eql 'An apple' | ||
| context 'capitalize the article when the noun has a consonant', -> | ||
| Then -> @subject('banana', true).should.eql 'A banana' | ||
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
16396
29.47%27
12.5%220
61.76%35
12.9%24
60%1
Infinity%