Socket
Socket
Sign inDemoInstall

check-ends-with-period

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

lib/check-ends-with-period.d.ts

63

lib/check-ends-with-period.js

@@ -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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc