Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

indefinite

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indefinite - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

.eslint.json

16

CONTRIBUTING.md

@@ -7,3 +7,3 @@ # Contributing

Please try to adhere, as close as possible, to the style and structure already present in this repository. I understand that people like things different ways, but as this is my repository, we'll be using my style preferences. If your pull request does not conform to this style, I'll simply ask you to clean it up. Please don't be offended. It doesn't mean I think your style preference is wrong or that mine is better. I just believe consistency is important in a repository. Notably, that means (among other things):
Please try to adhere, as close as possible, to the style and structure already present in this repository. Please don't be offended if I ask you clean something up, as consistency is important. Please see the `.eslint.json` config for a comprehensive style guide. Some of the more salient points follow:

@@ -25,4 +25,10 @@ 1. Two spaces. No literal tabs.

unless you're exporting a single a function.
unless you're exporting a single a function, like
```
module.exports = function() {
}
```
4. Use spaces at the beginning and end of inline objects and arrays: `{ foo: 'bar' }` and `[ 'foo', 'bar' ]`

@@ -64,3 +70,3 @@ 5. But . . . if you have longer objects, please use line breaks like this:

11. Be DRY. If you find yourself reusing code, pull it out into a separate function.
12. No coffeescript except in tests.
12. No coffeescript, typescript, or flow. I like javascript the way it is. Please do use es6 features if you like though.
13. Please comment where appropriate. When in doubt, add a comment. I'm finding more and more that things that seem self-documenting when I write them are actually semi-incomprehensible when I read them. Inline comments are fine most of the time, though jsdoc style block comments before functions are nice too.

@@ -70,6 +76,6 @@

Please write tests for any added feature or bug fix. I use coffeescript for tests, with mocha and mocha-given, which has a nice, terse syntax. Tests are run with gulp.
Please write tests for any added feature or bug fix. Tests are run with gulp.
## Commits and Git History
I actually don't care much about commit message formatting or keeping a clean history via squashes. Obviously, if you _want_ to do those things, go for the gold. In general, I think a commit message should be atomic (which is to say, if you need to use the word "and," then it should be two commits), should summarize the changes in the commit, and should use present tense, as in "Fix bug" (not "Fixed" or "Fixes").
I actually don't care much about commit message formatting or keeping a clean history via squashes. Obviously, if you _want_ to do those things, that's fine, but I won't make you. In general, I think a commit message should be atomic (which is to say, if you need to use the word "and," then it should be two commits), should summarize the changes in the commit, and should use present tense, as in "Fix bug" (not "Fixed" or "Fixes").

@@ -1,13 +0,6 @@

var gulp = require('gulp');
var clean = require('gulp-clean');
const gulp = require('gulp');
const rimraf = require('rimraf');
gulp.task('clean:coverage', function() {
return gulp.src('./coverage', { read: false })
.pipe(clean());
});
gulp.task('clean:coverage', done => rimraf('./coverage', done));
gulp.task('clean:dist', done => rimraf('./dist', done));
gulp.task('clean:dist', function() {
return gulp.src('./dist', { read: false })
.pipe(clean());
});

@@ -1,13 +0,14 @@

var gulp = require('gulp');
var cp = require('child_process');
var codeclimate = require('gulp-codeclimate-reporter');
const gulp = require('gulp');
const codeclimate = require('gulp-codeclimate-reporter');
gulp.task('codeclimate', function() {
if (process.version.indexOf('v4') > -1) {
gulp.src('coverage/lcov.info', { read: false })
gulp.task('codeclimate', (done) => {
if (process.version.indexOf('v8') > -1) {
return gulp.src('coverage/lcov.info', { read: false })
.pipe(codeclimate({
token: '7db887541ba6df3075e3a6ead2456b0ddf6bee65969308191c62afe1ea461566'
token: process.env.CODECLIMATE_REPO_TOKEN
}));
} else {
done();
}
});

@@ -0,4 +1,7 @@

const path = require('path');
module.exports = {
tests: ['test/**/*.coffee'],
root: path.resolve(__dirname, '..') + path.sep,
tests: ['test/**/*.js'],
lib: ['lib/**/*.js']
};

@@ -1,6 +0,6 @@

var gulp = require('gulp');
var Server = require('karma').Server;
var path = require('path');
const gulp = require('gulp');
const Server = require('karma').Server;
const path = require('path');
gulp.task('browser', function(done) {
gulp.task('browser', (done) => {
new Server({

@@ -12,3 +12,3 @@ configFile: path.resolve(__dirname, '../karma.conf.js'),

gulp.task('phantom', function(done) {
gulp.task('phantom', (done) => {
new Server({

@@ -21,3 +21,3 @@ configFile: path.resolve(__dirname, '../karma.conf.js'),

gulp.task('ci', function(done) {
gulp.task('ci', (done) => {
new Server({

@@ -24,0 +24,0 @@ configFile: path.resolve(__dirname, '../karma.conf.js')

@@ -1,17 +0,11 @@

var gulp = require('gulp');
var config = require('./config');
var jshint = require('gulp-jshint');
const gulp = require('gulp');
const config = require('./config');
const eslint = require('gulp-eslint');
gulp.task('lint', function() {
gulp.task('lint', () => {
return gulp.src(config.lib)
.pipe(jshint({
lookup: false,
eqeqeq: true,
es3: true,
indent: 2,
newcap: true,
quotmark: 'single',
boss: true
})).pipe(jshint.reporter('jshint-stylish'));
.pipe(eslint(config.root + '.eslint.json'))
.pipe(eslint.format('node_modules/eslint-codeframe-formatter'))
.pipe(eslint.failAfterError());
});

@@ -1,8 +0,8 @@

var gulp = require('gulp');
var open = require('gulp-open');
const gulp = require('gulp');
const open = require('gulp-open');
gulp.task('open', function() {
return gulp.src('./coverage/lcov-report/index.html')
gulp.task('open', () => {
return gulp.src('./coverage/lcov-report/index.html', { read: false })
.pipe(open());
});

@@ -1,6 +0,6 @@

var gulp = require('gulp');
var config = require('./config');
const gulp = require('gulp');
const config = require('./config');
gulp.task('watch', function() {
gulp.watch(config.lib.concat(config.tests), ['unit']);
gulp.task('watch', () => {
gulp.watch(config.lib.concat(config.tests), gulp.series('cover'));
});

@@ -1,7 +0,9 @@

var gulp = require('gulp');
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('build', sequence('clean:dist', ['copy', 'uglify']));
const gulp = require('gulp');
require('file-manifest').generate('./gulp', { match: '*.js' });
gulp.task('cover', gulp.series('clean:coverage', 'spawn:nyc'));
gulp.task('ci', gulp.series(gulp.parallel('lint', 'cover', 'phantom'), 'codeclimate'));
gulp.task('test', gulp.series('cover', 'browser'));
gulp.task('unit', gulp.series('spawn:nyc'));
gulp.task('default', gulp.series('lint', 'test'));
gulp.task('build', gulp.series('clean:dist', 'spawn:webpack'));

@@ -6,70 +6,39 @@ // Karma configuration

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'],
reporters: ['dots'],
browsers: ['Chrome', 'PhantomJS'],
preprocessors: {
'test/**/*.js': ['webpack']
},
// 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'
'test/**/*.js'
],
// 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']
webpack: {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
['env', { modules: false }]
]
}
}
]
}
]
}
},
// 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
})
logLevel: config.LOG_ERROR
});
}

@@ -1,19 +0,11 @@

(function() {
var isNode = (typeof module !== 'undefined' && this.module !== module);
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;
}
};
/* istanbul ignore else */
if (isNode) {
module.exports = indefinite;
module.exports = (noun, opts = {}) => {
let isAcronymWithU = opts.caseInsensitive ? false : /^U[A-Z]+$/.test(noun.split(' ')[0]);
let startsWithVowel = /[aeiou]/.test(noun.charAt(0).toLowerCase());
let article = !isAcronymWithU && startsWithVowel ? 'an ' : 'a ';
let phrase = article + noun;
if (opts.capitalize) {
return phrase.charAt(0).toUpperCase() + phrase.slice(1);
} else {
window.indefinite = indefinite;
return phrase;
}
})();
};
{
"name": "indefinite",
"description": "Prefix a noun with an indefinite article - a or an - based on whether it begins with a vowel",
"version": "1.0.1",
"version": "2.0.0",
"main": "lib/indefinite.js",
"scripts": {
"test": "gulp"
"test": "gulp",
"travis": "gulp ci",
"cover": "nyc --reporter=html --reporter=lcov --reporter=text-summary mocha --timeout=3000 --reporter=dot test/**/*.js"
},

@@ -32,27 +34,23 @@ "repository": {

"devDependencies": {
"coffee-script": "^1.10.0",
"file-manifest": "^1.0.3",
"gulp": "^3.9.0",
"gulp-clean": "^0.3.1",
"gulp-codeclimate-reporter": "^1.0.0",
"gulp-istanbul": "^0.10.2",
"gulp-jshint": "^1.11.2",
"gulp-mocha": "^2.1.3",
"gulp-open": "^1.0.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"eslint-codeframe-formatter": "^1.0.2",
"file-manifest": "^2.0.4",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-codeclimate-reporter": "github:tandrewnichols/gulp-codeclimate-reporter",
"gulp-eslint": "^4.0.0",
"gulp-open": "^2.0.0",
"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"
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-webpack": "^2.0.9",
"mocha": "^4.0.1",
"nyc": "^11.4.1",
"rimraf": "^2.6.2",
"should": "^13.1.3",
"webpack": "^3.10.0"
}
}

@@ -13,3 +13,3 @@ [![Build Status](https://travis-ci.org/tandrewnichols/indefinite.png)](https://travis-ci.org/tandrewnichols/indefinite) [![downloads](http://img.shields.io/npm/dm/indefinite.svg)](https://npmjs.org/package/indefinite) [![npm](http://img.shields.io/npm/v/indefinite.svg)](https://npmjs.org/package/indefinite) [![Code Climate](https://codeclimate.com/github/tandrewnichols/indefinite/badges/gpa.svg)](https://codeclimate.com/github/tandrewnichols/indefinite) [![Test Coverage](https://codeclimate.com/github/tandrewnichols/indefinite/badges/coverage.svg)](https://codeclimate.com/github/tandrewnichols/indefinite) [![dependencies](https://david-dm.org/tandrewnichols/indefinite.png)](https://david-dm.org/tandrewnichols/indefinite) ![Size](https://img.shields.io/badge/size-187b-brightgreen.svg)

It's not hard to check whether a noun begins with a vowel and decide whether to prefix with "a" or "an," but I got tired of doing it manually every time. So now there's this. Just pass in the word, and `indefinite` will return the word prefixed with either "a " or "an " depending on the first letter of the word.
It's not hard to check whether a noun begins with a vowel and decide whether to prefix with "a" or "an," but I got tired of doing it manually every time. So now there's this. Just pass in the word, and `indefinite` will return the word prefixed with either "a " or "an " depending on the first letter of the word. Additionally, as of version 2.0.0, `indefinite` will attempt to detect when an acronym is passed in and treat the response differently. E.g. it should be "a UFO" not "an UFO" because of how we pronounce a long U. This isn't a perfect science, so you might have false positives.

@@ -23,6 +23,11 @@ ## Usage

console.log(a('banana')); // "a banana"
console.log(a('UFO')); // 'a UFO'
```
// 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'
Indefinite also accepts an options object as the second parameter. Currently, two options are supported: `capitalize`, for capitalizing the article, and `caseInsensitive` for ignoring the casing of the word passed in (i.e. bypassing the acronym checking). This is useful if, for some reason, you're yelling on the internet and want to make sure "UGLY GARDEN GNOME" doesn't become "a UGLY GARDEN GNOME."
```js
console.log(a('apple', { capitalize: true })); // 'An apple'
console.log(a('banana', { capitalize: true })); // 'A banana'
console.log(a('UGLY SWEATER', { caseInsensitve: true })); // 'an UGLY SWEATER'
```

@@ -29,0 +34,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc