@fc3/grammar 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +673 -0
- package/README.md +3 -0
- package/bin/compile +55 -0
- package/bin/install +5 -0
- package/bin/lint +12 -0
- package/bin/postpublish +5 -0
- package/bin/precompile +55 -0
- package/bin/prepublish +7 -0
- package/bin/remap-paths +120 -0
- package/bin/test +9 -0
- package/bin/test-one +32 -0
- package/dist/.keep +0 -0
- package/dist/.last-compile-time +1 -0
- package/dist/.last-publish-time +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +19 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/noun-inflector.d.ts +17 -0
- package/dist/src/noun-inflector.js +83 -0
- package/dist/src/noun-inflector.js.map +1 -0
- package/dist/src/utility/get-words-from-identifier.d.ts +2 -0
- package/dist/src/utility/get-words-from-identifier.js +10 -0
- package/dist/src/utility/get-words-from-identifier.js.map +1 -0
- package/dist/src/utility/pluralize.d.ts +2 -0
- package/dist/src/utility/pluralize.js +12 -0
- package/dist/src/utility/pluralize.js.map +1 -0
- package/dist/src/utility/singularize-or-pluralize.d.ts +2 -0
- package/dist/src/utility/singularize-or-pluralize.js +12 -0
- package/dist/src/utility/singularize-or-pluralize.js.map +1 -0
- package/dist/src/utility/singularize.d.ts +2 -0
- package/dist/src/utility/singularize.js +12 -0
- package/dist/src/utility/singularize.js.map +1 -0
- package/dist/src/verb-inflector.d.ts +21 -0
- package/dist/src/verb-inflector.js +265 -0
- package/dist/src/verb-inflector.js.map +1 -0
- package/dist/test/unit/index.d.ts +1 -0
- package/dist/test/unit/index.js +60 -0
- package/dist/test/unit/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +42 -0
package/bin/compile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
if [[ $1 == '--help' ]]; then
|
|
4
|
+
echo "Triggers recompilation of the source code for the current project."
|
|
5
|
+
echo "Supported flags:"
|
|
6
|
+
echo "--force : Bypasses any precompilation checks (cache, mutex, etc)"
|
|
7
|
+
echo " Use this if you want to recompile no matter what."
|
|
8
|
+
echo " "
|
|
9
|
+
exit 0
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
if [[ $1 != '--force' ]]; then
|
|
13
|
+
./bin/precompile
|
|
14
|
+
|
|
15
|
+
case $? in
|
|
16
|
+
1)
|
|
17
|
+
exit 1
|
|
18
|
+
;;
|
|
19
|
+
3)
|
|
20
|
+
exit 0
|
|
21
|
+
;;
|
|
22
|
+
esac
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
echo "Recompiling..."
|
|
26
|
+
mkdir -p dist
|
|
27
|
+
echo $$ > dist/.compile-lock
|
|
28
|
+
rm -f dist/.last-compile-time
|
|
29
|
+
|
|
30
|
+
project_dir="$(dirname $(dirname "$0"))"
|
|
31
|
+
|
|
32
|
+
if [[ $1 == '--force' ]]; then
|
|
33
|
+
rm -rf dist/src
|
|
34
|
+
rm -rf dist/test
|
|
35
|
+
./node_modules/.bin/tsc --declaration --project "$project_dir/config/tsconfig.json"
|
|
36
|
+
else
|
|
37
|
+
./node_modules/.bin/tsc --declaration --incremental --project "$project_dir/config/tsconfig.json"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
exit_status=$?
|
|
41
|
+
|
|
42
|
+
if [[ $exit_status -eq 0 ]]; then
|
|
43
|
+
./bin/remap-paths
|
|
44
|
+
echo $(date +%s) > dist/.last-compile-time
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
pid=$(cat dist/.compile-lock)
|
|
48
|
+
|
|
49
|
+
if [[ $pid == $$ ]]; then
|
|
50
|
+
rm dist/.compile-lock
|
|
51
|
+
exit $exit_status
|
|
52
|
+
else
|
|
53
|
+
echo "Detected a conflicting compile lock..."
|
|
54
|
+
exit 1
|
|
55
|
+
fi
|
package/bin/install
ADDED
package/bin/lint
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
if [[ "${1:-}" == "--fix" ]]; then
|
|
6
|
+
./node_modules/.bin/eslint "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}" --fix
|
|
7
|
+
./node_modules/.bin/prettier --write "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}"
|
|
8
|
+
else
|
|
9
|
+
./node_modules/.bin/eslint "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}"
|
|
10
|
+
./node_modules/.bin/prettier --check "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}"
|
|
11
|
+
fi
|
|
12
|
+
|
package/bin/postpublish
ADDED
package/bin/precompile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
mkdir -p dist
|
|
4
|
+
|
|
5
|
+
if [ -f dist/.compile-lock ]; then
|
|
6
|
+
pid=$(cat dist/.compile-lock)
|
|
7
|
+
ticks=0
|
|
8
|
+
max_ticks=10
|
|
9
|
+
|
|
10
|
+
if ! ps -p $pid > /dev/null; then
|
|
11
|
+
echo "Detected a stale compile lock; deleting..."
|
|
12
|
+
rm -f dist/.compile-lock
|
|
13
|
+
else
|
|
14
|
+
echo "Compilation already in progress; waiting up to $max_ticks seconds..."
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
while [ -f dist/.compile-lock ]; do
|
|
18
|
+
sleep 1
|
|
19
|
+
let ticks=ticks+1
|
|
20
|
+
|
|
21
|
+
if [ $ticks -ge $max_ticks ]; then
|
|
22
|
+
echo "Timed out waiting for compilation to clear"
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
done
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [[ -f ./dist/.last-publish-time ]]; then
|
|
29
|
+
echo "Found publication compile artifact; skipping recompilation."
|
|
30
|
+
exit 3
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
if [ -f dist/.last-compile-time ]; then
|
|
34
|
+
if [ ! -d src ]; then
|
|
35
|
+
# TODO: Confirm we're within a deploy environment
|
|
36
|
+
echo "src folder does not exist; skipping recompilation."
|
|
37
|
+
exit 3
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
typeset -i last_modification_time=$(find src test -type f -print0 |
|
|
41
|
+
xargs -0 stat -c "%X %N" |
|
|
42
|
+
sort -rn |
|
|
43
|
+
head -1 |
|
|
44
|
+
awk '{ print $1 }')
|
|
45
|
+
|
|
46
|
+
typeset -i last_compile_time=$(cat dist/.last-compile-time)
|
|
47
|
+
|
|
48
|
+
if (( $last_compile_time > $last_modification_time )); then
|
|
49
|
+
echo "No changes since last compile; skipping recompilation."
|
|
50
|
+
exit 3
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Compilation should occur.
|
|
55
|
+
exit 0
|
package/bin/prepublish
ADDED
package/bin/remap-paths
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const FS = require('fs');
|
|
4
|
+
const Path = require('path');
|
|
5
|
+
|
|
6
|
+
const JAVASCRIPT_EXTENSION = '.js';
|
|
7
|
+
const DECLARATION_EXTENSION = '.d.ts';
|
|
8
|
+
const UTF8_ENCODING = 'utf8';
|
|
9
|
+
const DIST_PATH = Path.resolve(__dirname, '../dist');
|
|
10
|
+
|
|
11
|
+
function processDirectory(directoryPath) {
|
|
12
|
+
const children = FS.readdirSync(directoryPath);
|
|
13
|
+
|
|
14
|
+
children.forEach(function each(child) {
|
|
15
|
+
// Ignore hidden files.
|
|
16
|
+
if (child[0] === '.') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const
|
|
21
|
+
childPath = Path.resolve(directoryPath, child),
|
|
22
|
+
parsedPath = Path.parse(childPath);
|
|
23
|
+
|
|
24
|
+
if (!parsedPath.ext) {
|
|
25
|
+
processDirectory(childPath);
|
|
26
|
+
} else if (parsedPath.ext === JAVASCRIPT_EXTENSION) {
|
|
27
|
+
processSourceFile(childPath);
|
|
28
|
+
} else if (childPath.slice(-5) === DECLARATION_EXTENSION) {
|
|
29
|
+
processDeclarationFile(childPath);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function processSourceFile(filePath) {
|
|
35
|
+
const contents = FS.readFileSync(filePath, UTF8_ENCODING);
|
|
36
|
+
|
|
37
|
+
const lines = contents.split('\n').map(function map(line) {
|
|
38
|
+
return line.replace(/require\("([^"]+)/g, function replacer(match, path) {
|
|
39
|
+
if (path[0] === '.') {
|
|
40
|
+
return match;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let dependencyPath = DIST_PATH + '/src/' + path + '.js';
|
|
44
|
+
|
|
45
|
+
if (!FS.existsSync(dependencyPath)) {
|
|
46
|
+
// Fall back to checking whether there's an index.js in a directory
|
|
47
|
+
// of this name, instead of a toplevel .js source file directly.
|
|
48
|
+
dependencyPath = DIST_PATH + '/src/' + path + '/index.js';
|
|
49
|
+
|
|
50
|
+
if (!FS.existsSync(dependencyPath)) {
|
|
51
|
+
// Well, we tried.
|
|
52
|
+
return match;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const parsedFile = Path.parse(filePath);
|
|
57
|
+
const parsedDependency = Path.parse(dependencyPath);
|
|
58
|
+
|
|
59
|
+
let relativeDirectory = Path.relative(parsedFile.dir, parsedDependency.dir);
|
|
60
|
+
|
|
61
|
+
if (relativeDirectory === '') {
|
|
62
|
+
relativeDirectory = '.';
|
|
63
|
+
} else {
|
|
64
|
+
relativeDirectory = './' + relativeDirectory;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const relativePath = relativeDirectory + '/' + parsedDependency.base;
|
|
68
|
+
|
|
69
|
+
return 'require("' + relativePath;
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
FS.writeFileSync(filePath, lines.join('\n'), UTF8_ENCODING);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function processDeclarationFile(filePath) {
|
|
77
|
+
const contents = FS.readFileSync(filePath, UTF8_ENCODING);
|
|
78
|
+
|
|
79
|
+
const lines = contents.split('\n').map(function map(line) {
|
|
80
|
+
return line.replace(/from '([^']+)/g, function replacer(match, path) {
|
|
81
|
+
if (path[0] === '.') {
|
|
82
|
+
return match;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let dependencyPath = DIST_PATH + '/src/' + path + '.d.ts';
|
|
86
|
+
|
|
87
|
+
if (!FS.existsSync(dependencyPath)) {
|
|
88
|
+
// Fall back to checking whether there's an index.js in a directory
|
|
89
|
+
// of this name, instead of a toplevel .d.ts source file directly.
|
|
90
|
+
dependencyPath = DIST_PATH + '/src/' + path + '/index.d.ts';
|
|
91
|
+
|
|
92
|
+
if (!FS.existsSync(dependencyPath)) {
|
|
93
|
+
// Well, we tried.
|
|
94
|
+
return match;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const parsedFile = Path.parse(filePath);
|
|
99
|
+
const parsedDependency = Path.parse(dependencyPath);
|
|
100
|
+
|
|
101
|
+
let relativeDirectory = Path.relative(parsedFile.dir, parsedDependency.dir);
|
|
102
|
+
|
|
103
|
+
if (relativeDirectory === '') {
|
|
104
|
+
relativeDirectory = '.';
|
|
105
|
+
} else {
|
|
106
|
+
relativeDirectory = './' + relativeDirectory;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let relativePath = relativeDirectory + '/' + parsedDependency.base;
|
|
110
|
+
|
|
111
|
+
relativePath = relativePath.replace(DECLARATION_EXTENSION, '');
|
|
112
|
+
|
|
113
|
+
return "from '" + relativePath;
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
FS.writeFileSync(filePath, lines.join('\n'), UTF8_ENCODING);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
processDirectory('./dist', 0);
|
package/bin/test
ADDED
package/bin/test-one
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
RED='\033[0;31m'
|
|
6
|
+
YELLOW='\033[0;33m'
|
|
7
|
+
RESET='\033[0m'
|
|
8
|
+
|
|
9
|
+
bin/compile
|
|
10
|
+
|
|
11
|
+
FILE_TO_TEST=$1
|
|
12
|
+
|
|
13
|
+
if [ -f "dist/$1.js" ]; then
|
|
14
|
+
TEST_FILEPATH="$FILE_TO_TEST.js"
|
|
15
|
+
else
|
|
16
|
+
# If someone enters the path to the corresponding Typescript file for a test,
|
|
17
|
+
# we should map this to the associated JS file in the dist/test directory:
|
|
18
|
+
FILE_WITH_CORRECTED_EXTENSION=${FILE_TO_TEST/.ts/.js}
|
|
19
|
+
|
|
20
|
+
if [ -f "dist/$FILE_WITH_CORRECTED_EXTENSION" ]; then
|
|
21
|
+
TEST_FILEPATH=$FILE_WITH_CORRECTED_EXTENSION
|
|
22
|
+
fi
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if [ -f "dist/$TEST_FILEPATH" ]; then
|
|
26
|
+
NODE_ENV=test node --test dist/$TEST_FILEPATH
|
|
27
|
+
else
|
|
28
|
+
echo ""
|
|
29
|
+
echo -e "${RED}[ERROR]${RESET} No test file(s) found matching '$1'"
|
|
30
|
+
echo -e "${YELLOW}Example:${RESET} dev test test/unit/logger"
|
|
31
|
+
echo ""
|
|
32
|
+
fi
|
package/dist/.keep
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1764429995
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1764430006
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as NounInflector } from './noun-inflector';
|
|
2
|
+
export { default as VerbInflector } from './verb-inflector';
|
|
3
|
+
export { default as getWordsFromIdentifier } from './utility/get-words-from-identifier';
|
|
4
|
+
export { default as singularize } from './utility/singularize';
|
|
5
|
+
export { default as pluralize } from './utility/pluralize';
|
|
6
|
+
export { default as singularizeOrPluralize } from './utility/singularize-or-pluralize';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.singularizeOrPluralize = exports.pluralize = exports.singularize = exports.getWordsFromIdentifier = exports.VerbInflector = exports.NounInflector = void 0;
|
|
7
|
+
var noun_inflector_1 = require("./noun-inflector.js");
|
|
8
|
+
Object.defineProperty(exports, "NounInflector", { enumerable: true, get: function () { return __importDefault(noun_inflector_1).default; } });
|
|
9
|
+
var verb_inflector_1 = require("./verb-inflector.js");
|
|
10
|
+
Object.defineProperty(exports, "VerbInflector", { enumerable: true, get: function () { return __importDefault(verb_inflector_1).default; } });
|
|
11
|
+
var get_words_from_identifier_1 = require("./utility/get-words-from-identifier.js");
|
|
12
|
+
Object.defineProperty(exports, "getWordsFromIdentifier", { enumerable: true, get: function () { return __importDefault(get_words_from_identifier_1).default; } });
|
|
13
|
+
var singularize_1 = require("./utility/singularize.js");
|
|
14
|
+
Object.defineProperty(exports, "singularize", { enumerable: true, get: function () { return __importDefault(singularize_1).default; } });
|
|
15
|
+
var pluralize_1 = require("./utility/pluralize.js");
|
|
16
|
+
Object.defineProperty(exports, "pluralize", { enumerable: true, get: function () { return __importDefault(pluralize_1).default; } });
|
|
17
|
+
var singularize_or_pluralize_1 = require("./utility/singularize-or-pluralize.js");
|
|
18
|
+
Object.defineProperty(exports, "singularizeOrPluralize", { enumerable: true, get: function () { return __importDefault(singularize_or_pluralize_1).default; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwD;AAAhD,gIAAA,OAAO,OAAiB;AAChC,iDAAwD;AAAhD,gIAAA,OAAO,OAAiB;AAChC,+EAAoF;AAA5E,oJAAA,OAAO,OAA0B;AACzC,mDAA2D;AAAnD,2HAAA,OAAO,OAAe;AAC9B,+CAAuD;AAA/C,uHAAA,OAAO,OAAa;AAC5B,6EAAmF;AAA3E,mJAAA,OAAO,OAA0B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare class NounInflector {
|
|
2
|
+
singularize(plural_form: string): string;
|
|
3
|
+
pluralize(singular_form: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Takes a number, and a singular suffix noun, and returns the correctly
|
|
6
|
+
* formatted result for the given number.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* singularizeOrPluralize(1, 'account') => '1 account'
|
|
11
|
+
* singularizeOrPluralize(6, 'account') => '6 accounts'
|
|
12
|
+
*/
|
|
13
|
+
singularizeOrPluralize(amount: string | number, suffix: string): string;
|
|
14
|
+
prependArticle(suffix: string): string;
|
|
15
|
+
private isVowel;
|
|
16
|
+
}
|
|
17
|
+
export default NounInflector;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SINGULAR_TO_PLURAL_MAP = {
|
|
4
|
+
loot: 'loot'
|
|
5
|
+
};
|
|
6
|
+
class NounInflector {
|
|
7
|
+
singularize(plural_form) {
|
|
8
|
+
for (const singular_key in SINGULAR_TO_PLURAL_MAP) {
|
|
9
|
+
if (SINGULAR_TO_PLURAL_MAP[singular_key] === plural_form) {
|
|
10
|
+
return singular_key;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (plural_form.slice(-3) === 'ies') {
|
|
14
|
+
return plural_form.slice(0, -3) + 'y';
|
|
15
|
+
}
|
|
16
|
+
if (plural_form.slice(-1) === 'i') {
|
|
17
|
+
return plural_form.slice(0, -1) + 'us';
|
|
18
|
+
}
|
|
19
|
+
if (plural_form.slice(-1) === 's') {
|
|
20
|
+
return plural_form.slice(0, -1);
|
|
21
|
+
}
|
|
22
|
+
return plural_form;
|
|
23
|
+
}
|
|
24
|
+
pluralize(singular_form) {
|
|
25
|
+
if (SINGULAR_TO_PLURAL_MAP[singular_form] !== undefined) {
|
|
26
|
+
return SINGULAR_TO_PLURAL_MAP[singular_form];
|
|
27
|
+
}
|
|
28
|
+
if (singular_form.slice(-1) === 'y') {
|
|
29
|
+
if (!this.isVowel(singular_form.slice(-2, -1))) {
|
|
30
|
+
return singular_form.slice(0, -1) + 'ies';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (singular_form.slice(-2) === 'ch') {
|
|
34
|
+
return singular_form + 'es';
|
|
35
|
+
}
|
|
36
|
+
if (singular_form.slice(-2) === 'us') {
|
|
37
|
+
return singular_form.slice(0, -2) + 'i';
|
|
38
|
+
}
|
|
39
|
+
if (singular_form.slice(-2) === 'ss') {
|
|
40
|
+
return singular_form + 'es';
|
|
41
|
+
}
|
|
42
|
+
if (singular_form === 'life') {
|
|
43
|
+
return 'lives';
|
|
44
|
+
}
|
|
45
|
+
return singular_form + 's';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Takes a number, and a singular suffix noun, and returns the correctly
|
|
49
|
+
* formatted result for the given number.
|
|
50
|
+
*
|
|
51
|
+
* Example:
|
|
52
|
+
*
|
|
53
|
+
* singularizeOrPluralize(1, 'account') => '1 account'
|
|
54
|
+
* singularizeOrPluralize(6, 'account') => '6 accounts'
|
|
55
|
+
*/
|
|
56
|
+
singularizeOrPluralize(amount, suffix) {
|
|
57
|
+
if (typeof amount === 'string') {
|
|
58
|
+
amount = parseFloat(amount);
|
|
59
|
+
}
|
|
60
|
+
if (amount === 1) {
|
|
61
|
+
return `${amount} ${suffix}`;
|
|
62
|
+
}
|
|
63
|
+
const plural_suffix = this.pluralize(suffix);
|
|
64
|
+
return `${amount} ${plural_suffix}`;
|
|
65
|
+
}
|
|
66
|
+
prependArticle(suffix) {
|
|
67
|
+
const first_letter = suffix[0];
|
|
68
|
+
const is_vowel = this.isVowel(first_letter);
|
|
69
|
+
let article;
|
|
70
|
+
if (is_vowel) {
|
|
71
|
+
article = 'an';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
article = 'a';
|
|
75
|
+
}
|
|
76
|
+
return `${article} ${suffix}`;
|
|
77
|
+
}
|
|
78
|
+
isVowel(letter) {
|
|
79
|
+
return /[aeiou]/.test(letter.toLowerCase());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = NounInflector;
|
|
83
|
+
//# sourceMappingURL=noun-inflector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noun-inflector.js","sourceRoot":"","sources":["../../src/noun-inflector.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function getWordsFromIdentifier(identifier) {
|
|
4
|
+
const delimited_identifier = identifier.replace(/[a-z][A-Z]/g, (match) => {
|
|
5
|
+
return match[0] + '_' + match[1];
|
|
6
|
+
});
|
|
7
|
+
return delimited_identifier.split('_');
|
|
8
|
+
}
|
|
9
|
+
exports.default = getWordsFromIdentifier;
|
|
10
|
+
//# sourceMappingURL=get-words-from-identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-words-from-identifier.js","sourceRoot":"","sources":["../../../src/utility/get-words-from-identifier.ts"],"names":[],"mappings":";;AAAA,SAAS,sBAAsB,CAAC,UAAkB;IACjD,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;QACxE,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const noun_inflector_1 = __importDefault(require("./../noun-inflector.js"));
|
|
7
|
+
function pluralize(word) {
|
|
8
|
+
const inflector = new noun_inflector_1.default();
|
|
9
|
+
return inflector.pluralize(word);
|
|
10
|
+
}
|
|
11
|
+
exports.default = pluralize;
|
|
12
|
+
//# sourceMappingURL=pluralize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluralize.js","sourceRoot":"","sources":["../../../src/utility/pluralize.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAE3C,SAAS,SAAS,CAAC,IAAY;IAC9B,MAAM,SAAS,GAAG,IAAI,wBAAa,EAAE,CAAC;IAEtC,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const noun_inflector_1 = __importDefault(require("./../noun-inflector.js"));
|
|
7
|
+
function singularizeOrPluralize(count, word) {
|
|
8
|
+
const inflector = new noun_inflector_1.default();
|
|
9
|
+
return inflector.singularizeOrPluralize(count, word);
|
|
10
|
+
}
|
|
11
|
+
exports.default = singularizeOrPluralize;
|
|
12
|
+
//# sourceMappingURL=singularize-or-pluralize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singularize-or-pluralize.js","sourceRoot":"","sources":["../../../src/utility/singularize-or-pluralize.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAE3C,SAAS,sBAAsB,CAAC,KAAa,EAAE,IAAY;IAC1D,MAAM,SAAS,GAAG,IAAI,wBAAa,EAAE,CAAC;IAEtC,OAAO,SAAS,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const noun_inflector_1 = __importDefault(require("./../noun-inflector.js"));
|
|
7
|
+
function singularize(word) {
|
|
8
|
+
const inflector = new noun_inflector_1.default();
|
|
9
|
+
return inflector.singularize(word);
|
|
10
|
+
}
|
|
11
|
+
exports.default = singularize;
|
|
12
|
+
//# sourceMappingURL=singularize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singularize.js","sourceRoot":"","sources":["../../../src/utility/singularize.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAE3C,SAAS,WAAW,CAAC,IAAY;IAChC,MAAM,SAAS,GAAG,IAAI,wBAAa,EAAE,CAAC;IAEtC,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare class VerbInflector {
|
|
2
|
+
private value;
|
|
3
|
+
private verb;
|
|
4
|
+
private suffix;
|
|
5
|
+
private uppercase;
|
|
6
|
+
constructor(value: string);
|
|
7
|
+
toPresentParticiple(): string;
|
|
8
|
+
toPastParticiple(): string;
|
|
9
|
+
toInfinitive(): string;
|
|
10
|
+
toAdjective(): string;
|
|
11
|
+
toPresentTense(): string;
|
|
12
|
+
toImperfectTense(): string;
|
|
13
|
+
toPastTense(): string;
|
|
14
|
+
toFutureTense(): string;
|
|
15
|
+
toSingularNoun(): string;
|
|
16
|
+
toPluralNoun(): string;
|
|
17
|
+
toSingularActor(): string;
|
|
18
|
+
toPluralActor(): string;
|
|
19
|
+
private finalize;
|
|
20
|
+
}
|
|
21
|
+
export default VerbInflector;
|