1.0.0 • Published 1 year ago
word-postfixes v1.0.0
word-postfixes
This package returns all the postfixes of a given word.
Installation
npm install word-postfixesUsage
const getPostfixes = require('word-postfixes');
console.log(getPostfixes('postfix')); 
// Output: ['postfix', 'ostfix', 'stfix', 'tfix', 'fix', 'ix', 'x']
console.log(getPostfixes('a')); 
// Output: ['a']
console.log(getPostfixes('')); 
// Output: []
console.log(getPostfixes(123)); 
// Output: ['123', '23', '3']
// If a non-string or non-number is passed, an error will be thrown
try {
  console.log(getPostfixes({}));
} catch (error) {
  console.error(error.message); 
  // Output: Expected a string or a number
}Sample Results
Input: 'postfix'
['postfix', 'ostfix', 'stfix', 'tfix', 'fix', 'ix', 'x']Input: 'a'
['a']Input: '' (empty string)
[]Input: 123 (number)
['123', '23', '3']Input: {} (non-string/number)
TypeError: Expected a string or a numberLicense
MIT
1.0.0
1 year ago