check-ends-with-period
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -0,19 +1,17 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkEndsWithPeriod = void 0; | ||
// MIT © 2017 azu | ||
"use strict"; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var find = require("array.prototype.find"); | ||
var endWith = require("end-with"); | ||
var emojiRegExp = require("emoji-regex")(); | ||
var exceptionMarkRegExp = /[!?!?\))」』]/; | ||
const emoji_regex_1 = __importDefault(require("emoji-regex")); | ||
const emojiRegExp = (0, emoji_regex_1.default)(); | ||
const exceptionMarkRegExp = /[!?!?))」』]/; | ||
/** | ||
* Check ends with period. | ||
* @param {string} lineText | ||
* @param {string[]} periodMarks | ||
* @param {boolean} allowExceptionMark often used at end. | ||
* @param {boolean} allowEmoji | ||
* @param {string[]} [periodMarks] | ||
* @param {boolean} [allowExceptionMark] often used at end. | ||
* @param {boolean} [allowEmoji] | ||
* @returns {{valid: boolean, periodMark: string, index: number}} | ||
@@ -26,20 +24,13 @@ * | ||
*/ | ||
var checkEndsWithPeriod = function checkEndsWithPeriod(lineText) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref$periodMarks = _ref.periodMarks, | ||
periodMarks = _ref$periodMarks === undefined ? ["。", "."] : _ref$periodMarks, | ||
_ref$allowExceptionMa = _ref.allowExceptionMark, | ||
allowExceptionMark = _ref$allowExceptionMa === undefined ? true : _ref$allowExceptionMa, | ||
_ref$allowEmoji = _ref.allowEmoji, | ||
allowEmoji = _ref$allowEmoji === undefined ? false : _ref$allowEmoji; | ||
const checkEndsWithPeriod = function (lineText, { periodMarks = ["。", "."], allowExceptionMark = true, allowEmoji = false, } = {}) { | ||
// サロゲートペアを考慮した文字列長・文字アクセス | ||
var characters = [].concat(_toConsumableArray(lineText)); | ||
var lastCharacterIndex = characters.length - 1; | ||
var periodMark = characters[lastCharacterIndex]; | ||
const characters = [...lineText]; | ||
const lastCharacterIndex = characters.length - 1; | ||
const periodMark = characters[lastCharacterIndex]; | ||
if (/\s/.test(periodMark)) { | ||
var _lineText$match = lineText.match(/\s+$/), | ||
_lineText$match2 = _slicedToArray(_lineText$match, 1), | ||
whiteSpaces = _lineText$match2[0]; | ||
const result = lineText.match(/\s+$/); | ||
if (!result) { | ||
return; | ||
} | ||
const [whiteSpaces] = result; | ||
return { | ||
@@ -55,3 +46,3 @@ valid: false, | ||
valid: true, | ||
periodMark: periodMark, | ||
periodMark, | ||
index: lastCharacterIndex | ||
@@ -64,3 +55,3 @@ }; | ||
valid: true, | ||
periodMark: periodMark, | ||
periodMark, | ||
index: lastCharacterIndex | ||
@@ -72,4 +63,4 @@ }; | ||
*/ | ||
var matchMark = find(periodMarks, function (mark) { | ||
return endWith(lineText, mark); | ||
const matchMark = periodMarks.find(mark => { | ||
return lineText.endsWith(mark); | ||
}); | ||
@@ -85,7 +76,7 @@ if (matchMark) { | ||
valid: false, | ||
periodMark: periodMark, | ||
periodMark, | ||
index: lastCharacterIndex | ||
}; | ||
}; | ||
module.exports = checkEndsWithPeriod; | ||
exports.checkEndsWithPeriod = checkEndsWithPeriod; | ||
//# sourceMappingURL=check-ends-with-period.js.map |
{ | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"author": "azu", | ||
"license": "MIT", | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"src/" | ||
], | ||
"name": "check-ends-with-period", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Check the text is ends with period mark.", | ||
"main": "lib/check-ends-with-period.js", | ||
"scripts": { | ||
"test": "mocha test/", | ||
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps", | ||
"watch": "babel src --out-dir lib --watch --source-maps", | ||
"prepublish": "npm run --if-present build" | ||
}, | ||
"keywords": [ | ||
@@ -26,2 +9,6 @@ "text", | ||
], | ||
"homepage": "https://github.com/azu/check-ends-with-period", | ||
"bugs": { | ||
"url": "https://github.com/azu/check-ends-with-period/issues" | ||
}, | ||
"repository": { | ||
@@ -31,21 +18,39 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/azu/check-ends-with-period/issues" | ||
"license": "MIT", | ||
"author": "azu", | ||
"type": "module", | ||
"main": "lib/check-ends-with-period.js", | ||
"module": "module/check-ends-with-period.js", | ||
"types": "lib/check-ends-with-period.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./lib/check-ends-with-period.js", | ||
"import": "./module/check-ends-with-period.js" | ||
} | ||
}, | ||
"homepage": "https://github.com/azu/check-ends-with-period", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.0", | ||
"babel-preset-jsdoc-to-assert": "^4.0.0", | ||
"babel-preset-latest": "^6.24.0", | ||
"babel-preset-power-assert": "^1.0.0", | ||
"babel-register": "^6.24.0", | ||
"cross-env": "^3.2.4", | ||
"mocha": "^3.2.0", | ||
"power-assert": "^1.4.2" | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"module/", | ||
"src/" | ||
], | ||
"scripts": { | ||
"build": "tsc -p . && tsc -p tsconfig.cjs.json", | ||
"prepublishOnly": "npm run build", | ||
"test": "mocha \"test/**/*.{js,ts}\"", | ||
"watch": "tsc -p . --watch" | ||
}, | ||
"dependencies": { | ||
"array.prototype.find": "^2.0.3", | ||
"emoji-regex": "^6.4.1", | ||
"end-with": "^1.0.2" | ||
"emoji-regex": "^10.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^17.0.42", | ||
"mocha": "^10.0.0", | ||
"ts-node": "^10.8.1", | ||
"typescript": "^4.7.3" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# check-ends-with-period [![Build Status](https://travis-ci.org/azu/check-ends-with-period.svg?branch=master)](https://travis-ci.org/azu/check-ends-with-period) | ||
# check-ends-with-period [![Actions Status: test](https://github.com/azu/check-ends-with-period/workflows/test/badge.svg)](https://github.com/azu/check-ends-with-period/actions?query=workflow%3A"test") | ||
@@ -17,5 +17,5 @@ Check the text is ends with period mark. | ||
* @param {string} lineText | ||
* @param {string[]} periodMarks | ||
* @param {boolean} allowExceptionMark often used at end. | ||
* @param {boolean} allowEmoji | ||
* @param {string[]} [periodMarks] | ||
* @param {boolean} [allowExceptionMark] often used at end. | ||
* @param {boolean} [allowEmoji] | ||
* @returns {{valid: boolean, periodMark: string, index: number}} | ||
@@ -22,0 +22,0 @@ * |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17196
1
5
10
269
Yes
1
+ Addedemoji-regex@10.3.0(transitive)
- Removedarray.prototype.find@^2.0.3
- Removedend-with@^1.0.2
- Removedarray-buffer-byte-length@1.0.1(transitive)
- Removedarray.prototype.find@2.2.3(transitive)
- Removedarraybuffer.prototype.slice@1.0.3(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removeddata-view-buffer@1.0.1(transitive)
- Removeddata-view-byte-length@1.0.1(transitive)
- Removeddata-view-byte-offset@1.0.0(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removedemoji-regex@6.5.1(transitive)
- Removedend-with@1.0.2(transitive)
- Removedes-abstract@1.23.3(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes-set-tostringtag@2.0.3(transitive)
- Removedes-shim-unscopables@1.0.2(transitive)
- Removedes-to-primitive@1.2.1(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.6(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedget-symbol-description@1.0.2(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-bigints@1.0.2(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinternal-slot@1.0.7(transitive)
- Removedis-array-buffer@3.0.4(transitive)
- Removedis-bigint@1.0.4(transitive)
- Removedis-boolean-object@1.1.2(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.1(transitive)
- Removedis-date-object@1.0.5(transitive)
- Removedis-negative-zero@2.0.3(transitive)
- Removedis-number-object@1.0.7(transitive)
- Removedis-regex@1.1.4(transitive)
- Removedis-shared-array-buffer@1.0.3(transitive)
- Removedis-string@1.0.7(transitive)
- Removedis-symbol@1.0.4(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedis-weakref@1.0.2(transitive)
- Removedisarray@2.0.5(transitive)
- Removedobject-inspect@1.13.1(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedregexp.prototype.flags@1.5.2(transitive)
- Removedsafe-array-concat@1.1.2(transitive)
- Removedsafe-regex-test@1.0.3(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedstring.prototype.trim@1.2.9(transitive)
- Removedstring.prototype.trimend@1.0.8(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedtyped-array-buffer@1.0.2(transitive)
- Removedtyped-array-byte-length@1.0.1(transitive)
- Removedtyped-array-byte-offset@1.0.2(transitive)
- Removedtyped-array-length@1.0.6(transitive)
- Removedunbox-primitive@1.0.2(transitive)
- Removedwhich-boxed-primitive@1.0.2(transitive)
- Removedwhich-typed-array@1.1.15(transitive)
Updatedemoji-regex@^10.1.0