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

syllable

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syllable - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

31

cli.js

@@ -15,3 +15,3 @@ #!/usr/bin/env node

/* Command. */
var command = Object.keys(pack.bin)[0];
var command = pack.name;

@@ -39,9 +39,3 @@ /* Program. */

return;
/**
* Get the syllables in a document.
*
* @param {string?} value
*/
/* Get the syllables in a document. */
function getSyllables(value) {

@@ -58,8 +52,3 @@ value = value.split(/\s+/g).map(trim).filter(Boolean);

/**
* Get the syllables for multiple words.
*
* @param {Array.<string>} values
* @return {number}
*/
/* Get the syllables for multiple words. */
function syllables(values) {

@@ -69,7 +58,3 @@ return values.map(syllable).reduce(sum);

/**
* Help.
*
* @return {string}
*/
/* Help. */
function help() {

@@ -100,11 +85,5 @@ return [

/**
* Add `a` to `b`.
*
* @param {number} a
* @param {number} b
* @return {number}
*/
/* Add `a` to `b`. */
function sum(a, b) {
return a + b;
}

97

index.js

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

/**
* @author Titus Wormer
* @copyright 2014 Titus Wormer
* @license MIT
* @module syllable
* @fileoverview Count syllables in English words.
*/
'use strict';

@@ -14,6 +6,7 @@

var pluralize = require('pluralize');
var normalize = require('normalize-strings');
var problematic = require('./problematic');
/* Expose. */
module.exports = syllable;
module.exports = syllables;

@@ -306,2 +299,5 @@ /* Two expressions of occurrences which normally would

/* Expression to split on word boundaries. */
var SPLIT = /\b/g;
/* Expression to remove non-alphabetic characters from

@@ -311,8 +307,17 @@ * a given value. */

/**
* Get syllables in a given value.
*
* @param {string} value
* @return {number}
*/
/* Wrapper to support multiple word-parts (GH-11). */
function syllables(value) {
var values = normalize(String(value)).toLowerCase().split(SPLIT);
var length = values.length;
var index = -1;
var total = 0;
while (++index < length) {
total += syllable(values[index].replace(EXPRESSION_NONALPHABETIC, ''));
}
return total;
}
/* Get syllables in a given value. */
function syllable(value) {

@@ -327,6 +332,2 @@ var count = 0;

value = String(value)
.toLowerCase()
.replace(EXPRESSION_NONALPHABETIC, '');
if (!value.length) {

@@ -355,36 +356,2 @@ return count;

/**
* Define scoped counters, to be used
* in `String#replace()` calls.
*
* The scoped counter removes the matched value
* from the input.
*
* @param {number} addition
* @return {function(): string}
*/
function countFactory(addition) {
return function () {
count += addition;
return '';
};
}
/**
* Define scoped counters, to be used
* in `String#replace()` calls.
*
* The scoped counter does not remove the matched
* value from the input.
*
* @param {number} addition
* @return {function(): string}
*/
function returnFactory(addition) {
return function ($0) {
count += addition;
return $0;
};
}
addOne = returnFactory(1);

@@ -427,2 +394,26 @@ subtractOne = returnFactory(-1);

return count || 1;
/* Define scoped counters, to be used
* in `String#replace()` calls.
* The scoped counter removes the matched value
* from the input. */
function countFactory(addition) {
return counter;
function counter() {
count += addition;
return '';
}
}
/* Define scoped counters, to be used
* in `String#replace()` calls.
* The scoped counter does not remove the matched
* value from the input. */
function returnFactory(addition) {
return returner;
function returner($0) {
count += addition;
return $0;
}
}
}
{
"name": "syllable",
"version": "1.0.0",
"version": "2.0.0",
"description": "Count syllables in English words",

@@ -14,7 +14,2 @@ "license": "MIT",

],
"dependencies": {
"has": "^1.0.1",
"pluralize": "^3.0.0",
"trim": "0.0.1"
},
"repository": "https://github.com/wooorm/syllable",

@@ -26,5 +21,2 @@ "bugs": "https://github.com/wooorm/syllable/issues",

],
"engines": {
"node": ">=0.11.0"
},
"files": [

@@ -35,4 +27,8 @@ "problematic.json",

],
"bin": {
"syllable": "cli.js"
"bin": "cli.js",
"dependencies": {
"has": "^1.0.1",
"normalize-strings": "^1.1.0",
"pluralize": "^3.0.0",
"trim": "0.0.1"
},

@@ -42,11 +38,8 @@ "devDependencies": {

"esmangle": "^1.0.0",
"execa": "^0.4.0",
"nyc": "^7.1.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-validate-links": "^4.0.0",
"execa": "^0.5.0",
"nyc": "^10.0.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"tape": "^4.4.0",
"xo": "^0.16.0"
"xo": "^0.17.0"
},

@@ -72,8 +65,7 @@ "scripts": {

"rules": {
"guard-for-in": "off",
"max-lines": "off"
"unicorn/explicit-length-check": "off",
"guard-for-in": "off"
},
"ignores": [
"syllable.js",
"syllable.min.js"
"syllable.js"
]

@@ -83,16 +75,4 @@ },

"output": true,
"plugins": {
"comment-config": null,
"lint": {
"heading-increment": false,
"no-duplicate-headings": false,
"list-item-spacing": false
},
"github": null,
"validate-links": null
},
"settings": {
"bullet": "*"
}
"presets": "wooorm"
}
}

@@ -23,2 +23,6 @@ # syllable [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

syllable('mmmmmmmmmmmmmmmm'); // 1
syllable('wine'); // 1
syllable('bottle'); // 2
syllable('wine-bottle'); // 3
syllable('Åland'); // 2
```

@@ -62,2 +66,4 @@

Support for word-breaks and non-ASCII characters added later.
## License

@@ -64,0 +70,0 @@

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