Skip to content

Commit

Permalink
feat: rewrite in TS
Browse files Browse the repository at this point in the history
  • Loading branch information
revelt committed Dec 25, 2020
1 parent 53da6d8 commit c2aa395
Show file tree
Hide file tree
Showing 12 changed files with 282 additions and 140 deletions.
3 changes: 2 additions & 1 deletion packages/string-character-is-astral-surrogate/.npmignore
@@ -1,4 +1,4 @@
# .... generated using www.npmjs.com/package/lect ....
# generated using codsen.com/os/lect
#
#
# __ ______ ______ ______
Expand All @@ -23,3 +23,4 @@ test
.prettierignore
rollup.config.js
testStats.md
tsconfig.json
Expand Up @@ -11,45 +11,43 @@

Object.defineProperty(exports, '__esModule', { value: true });

function _typeof(obj) {
"@babel/helpers - typeof";

if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}

return _typeof(obj);
}

// high surrogate goes first, low goes second
function isHighSurrogate(something) {
// [\uD800-\uDBFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
}
} // \uD800 charCode is 55296
// \uDBFF charCode is 56319


return something.charCodeAt(0) >= 55296 && something.charCodeAt(0) <= 56319;
}

if (something === undefined) {
return false;
}
throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ".concat(_typeof(something)));

throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but " + typeof something);
}

function isLowSurrogate(something) {
// [\uDC00-\uDFFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
}
} // \uDC00 charCode is 56320
// \uDFFF charCode is 57343


return something.charCodeAt(0) >= 56320 && something.charCodeAt(0) <= 57343;
}

if (something === undefined) {
return false;
}
throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ".concat(_typeof(something)));

throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but " + typeof something);
}

exports.isHighSurrogate = isHighSurrogate;
Expand Down
Expand Up @@ -8,69 +8,53 @@
*/

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.stringCharacterIsAstralSurrogate = {}));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.stringCharacterIsAstralSurrogate = {}));
}(this, (function (exports) { 'use strict';

function _typeof(obj) {
"@babel/helpers - typeof";
// high surrogate goes first, low goes second
function isHighSurrogate(something) {
// [\uD800-\uDBFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
} // \uD800 charCode is 55296
// \uDBFF charCode is 56319

if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}

return _typeof(obj);
return something.charCodeAt(0) >= 55296 && something.charCodeAt(0) <= 56319;
}

// high surrogate goes first, low goes second
function isHighSurrogate(something) {
// [\uD800-\uDBFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
} // \uD800 charCode is 55296
// \uDBFF charCode is 56319


return something.charCodeAt(0) >= 55296 && something.charCodeAt(0) <= 56319;
}

if (something === undefined) {
return false;
}

throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ".concat(_typeof(something)));
if (something === undefined) {
return false;
}

function isLowSurrogate(something) {
// [\uDC00-\uDFFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
} // \uDC00 charCode is 56320
// \uDFFF charCode is 57343
throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but " + typeof something);
}

function isLowSurrogate(something) {
// [\uDC00-\uDFFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
} // \uDC00 charCode is 56320
// \uDFFF charCode is 57343

return something.charCodeAt(0) >= 56320 && something.charCodeAt(0) <= 57343;
}

if (something === undefined) {
return false;
}
return something.charCodeAt(0) >= 56320 && something.charCodeAt(0) <= 57343;
}

throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ".concat(_typeof(something)));
if (something === undefined) {
return false;
}

exports.isHighSurrogate = isHighSurrogate;
exports.isLowSurrogate = isLowSurrogate;
throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but " + typeof something);
}

exports.isHighSurrogate = isHighSurrogate;
exports.isLowSurrogate = isLowSurrogate;

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });

})));
Expand Up @@ -7,33 +7,43 @@
* Homepage: https://codsen.com/os/string-character-is-astral-surrogate/
*/

// high surrogate goes first, low goes second
function isHighSurrogate(something) {
// [\uD800-\uDBFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
}
} // \uD800 charCode is 55296
// \uDBFF charCode is 56319


return something.charCodeAt(0) >= 55296 && something.charCodeAt(0) <= 56319;
}

if (something === undefined) {
return false;
}
throw new TypeError(
`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof something}`
);

throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof something}`);
}

function isLowSurrogate(something) {
// [\uDC00-\uDFFF]
if (typeof something === "string") {
if (something.length === 0) {
return false;
}
} // \uDC00 charCode is 56320
// \uDFFF charCode is 57343


return something.charCodeAt(0) >= 56320 && something.charCodeAt(0) <= 57343;
}

if (something === undefined) {
return false;
}
throw new TypeError(
`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof something}`
);

throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof something}`);
}

export { isHighSurrogate, isLowSurrogate };
@@ -0,0 +1,10 @@
/**
* string-character-is-astral-surrogate
* Tells, is given character a part of astral character, specifically, a high and low surrogate
* Version: 1.11.0
* Author: Roy Revelt, Codsen Ltd
* License: MIT
* Homepage: https://codsen.com/os/string-character-is-astral-surrogate/
*/

function r(r){if("string"==typeof r)return 0!==r.length&&(r.charCodeAt(0)>=55296&&56319>=r.charCodeAt(0));if(void 0===r)return!1;throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but "+typeof r)}function t(r){if("string"==typeof r)return 0!==r.length&&(r.charCodeAt(0)>=56320&&57343>=r.charCodeAt(0));if(void 0===r)return!1;throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but "+typeof r)}export{r as isHighSurrogate,t as isLowSurrogate};
Expand Up @@ -7,4 +7,4 @@
* Homepage: https://codsen.com/os/string-character-is-astral-surrogate/
*/

!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).stringCharacterIsAstralSurrogate={})}(this,(function(t){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}t.isHighSurrogate=function(t){if("string"==typeof t)return 0!==t.length&&(t.charCodeAt(0)>=55296&&t.charCodeAt(0)<=56319);if(void 0===t)return!1;throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ".concat(r(t)))},t.isLowSurrogate=function(t){if("string"==typeof t)return 0!==t.length&&(t.charCodeAt(0)>=56320&&t.charCodeAt(0)<=57343);if(void 0===t)return!1;throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ".concat(r(t)))},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).stringCharacterIsAstralSurrogate={})}(this,(function(t){"use strict";t.isHighSurrogate=function(t){if("string"==typeof t)return 0!==t.length&&(t.charCodeAt(0)>=55296&&56319>=t.charCodeAt(0));if(void 0===t)return!1;throw new TypeError("string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but "+typeof t)},t.isLowSurrogate=function(t){if("string"==typeof t)return 0!==t.length&&(t.charCodeAt(0)>=56320&&57343>=t.charCodeAt(0));if(void 0===t)return!1;throw new TypeError("string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but "+typeof t)},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1,5 +1,3 @@
/* eslint import/extensions:0 */

// Quick Take

import { strict as assert } from "assert";
Expand Down
59 changes: 26 additions & 33 deletions packages/string-character-is-astral-surrogate/package.json
Expand Up @@ -29,15 +29,17 @@
"main": "dist/string-character-is-astral-surrogate.cjs.js",
"module": "dist/string-character-is-astral-surrogate.esm.js",
"browser": "dist/string-character-is-astral-surrogate.umd.js",
"types": "types/main.d.ts",
"scripts": {
"build": "rollup -c",
"build": "npm run clean_types -- --pt1 && rollup -c && npm run clean_types -- --pt2",
"ci_test": "npm run build && npm run lint && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov && npm run format",
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
"dev": "rollup -c --dev",
"clean_types": "../../scripts/cleanTypes.js",
"dev": "npm run clean_types -- --pt1 && rollup -c --dev && npm run clean_types -- --pt2",
"devunittest": "npm run dev && ./node_modules/.bin/tap --only -R 'base' && npm run tsd && npm run clean_cov",
"format": "npm run lect && npm run prettier && npm run lint",
"lect": "lect",
"lint": "../../node_modules/eslint/bin/eslint.js \"**/*.js\" --fix --config \"../../.eslintrc.json\" --quiet",
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
"perf": "node perf/check",
"prepare": "npm run build",
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
Expand All @@ -46,15 +48,11 @@
"pretest": "npm run build",
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
"tsc": "tsc",
"tsd": "test ! -f index.d.ts || tsd",
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && npm run tsd && npm run clean_cov && npm run perf",
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc --noEmit && npm run tsd && npm run clean_cov && npm run perf",
"version": "npm run build && git add ."
},
"husky": {
"hooks": {
"pre-commit": "npm run format && npm test"
}
},
"tap": {
"coverage-report": [
"json-summary",
Expand All @@ -67,58 +65,53 @@
"timeout": 0
},
"lect": {
"defaultExported": false,
"files": {
"delete": [],
"write_hard": [
{
"contents": "",
"name": ""
}
],
"write_soft": [
{
"contents": "",
"name": ""
}
]
},
"licence": {
"extras": [
""
]
},
"npmignore": {
"badFiles": [],
"badFolders": [],
"goodFiles": [],
"goodFolders": []
},
"req": "{ isHighSurrogate, isLowSurrogate }",
"various": {
"devDependencies": []
}
},
"dependencies": {
"@babel/runtime": "^7.9.2"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"@babel/plugin-external-helpers": "^7.12.1",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/preset-typescript": "^7.12.7",
"@babel/register": "^7.12.10",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-replace": "^2.3.4",
"@rollup/plugin-strip": "^2.0.0",
"benchmark": "^2.1.4",
"@rollup/plugin-typescript": "^8.1.0",
"@types/node": "^13.13.4",
"@types/tap": "^14.10.1",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"eslint": "^7.15.0",
"fs-extra": "^9.0.1",
"lect": "^0.15.1",
"rollup": "^2.35.1",
"rollup-plugin-ascii": "^0.0.3",
"rollup-plugin-banner": "^0.2.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-terser": "^7.0.2",
"tap": "^14.11.0",
"tsd": "^0.14.0"
"tsd": "^0.14.0",
"tslib": "^2.0.3",
"typescript": "^4.1.3"
}
}

0 comments on commit c2aa395

Please sign in to comment.