@identity-js/string-identity 1.0.0 → 1.1.0

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.
Files changed (2) hide show
  1. package/index.js +19 -11
  2. package/package.json +1 -2
package/index.js CHANGED
@@ -5,7 +5,9 @@ var eqstrings = require("eq-strings")
5
5
  var isWDS = require("@overkill/is-wds").isWDS
6
6
  var { immediateError, ErrorType } = require("immediate-error")
7
7
  var getIntrinsic = require("get-intrinsic")
8
+ var $String = getIntrinsic("%String%")
8
9
  var fromCharCode = getIntrinsic("%String.fromCharCode%")
10
+ var isString = require("is-string")
9
11
 
10
12
  // LOWERCASE LETTERS
11
13
  var lowercase_a = require("@lowercase-letters/a") // "a"
@@ -131,7 +133,6 @@ var creashaksOrganzine = require("string-creashaks-organzine") // "creashaks org
131
133
  var emptyString = require("empty-string") // ""
132
134
  var space = require("space-string") // " "
133
135
 
134
-
135
136
  // EMOJIS
136
137
  var emojis = {
137
138
  "emoji-100": require("emoji-100"), // "💯"
@@ -385,16 +386,23 @@ var emojis = {
385
386
  "emoji-zero": require("emoji-zero") // "0️⃣"
386
387
  }
387
388
  function stringIdentity(str) {
388
- try {
389
- return stringIdentityCommonStrings(str)
390
- } catch {
391
- return generalConcat(...(splitString(str, emptyString).map((currentValue) => {
392
- try {
393
- return stringIdentityCommonStrings(currentValue)
394
- } catch {
395
- return fromCharCode(currentValue.charCodeAt(0))
396
- }
397
- })))
389
+ if (!isString(str) && ($String(str) === str)) {
390
+ return immediateError(
391
+ "The first argument to stringIdentity must be a string, and not an object string (e.g. new String(\"hi\")). Received: " + String(str),
392
+ ErrorType.TypeError
393
+ )
394
+ } else {
395
+ try {
396
+ return stringIdentityCommonStrings(str)
397
+ } catch {
398
+ return generalConcat(...(splitString(str, emptyString).map((currentValue) => {
399
+ try {
400
+ return stringIdentityCommonStrings(currentValue)
401
+ } catch {
402
+ return fromCharCode(currentValue.charCodeAt(0))
403
+ }
404
+ })))
405
+ }
398
406
  }
399
407
  }
400
408
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@identity-js/string-identity",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Returns the string passed into the function.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -340,7 +340,6 @@
340
340
  "string.prototype.split": "^1.0.9"
341
341
  },
342
342
  "devDependencies": {
343
- "all-the-package-names": "^2.0.2291",
344
343
  "chai": "^6.2.1",
345
344
  "mocha": "^11.7.5"
346
345
  }