@identity-js/identity 1.2.7 → 1.2.9
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/index.js +5 -1
- package/package.json +6 -5
- package/test/index.js +12 -0
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var identityfunction = require("identity-function")
|
|
|
10
10
|
var isFinite = require("@is-(unknown)/is-finite")
|
|
11
11
|
var isString = require("@is-(unknown)/is-string")
|
|
12
12
|
var asyncUtilIdentity = require("async.util.identity")
|
|
13
|
+
var id = require("js-id")
|
|
13
14
|
|
|
14
15
|
function identityCore(value) {
|
|
15
16
|
if (isString(value)) {
|
|
@@ -27,13 +28,16 @@ function identityCore(value) {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
function identity(value) {
|
|
31
|
+
if (Object.is(value, -0)) {
|
|
32
|
+
return -0
|
|
33
|
+
}
|
|
30
34
|
if (value === null || value === undefined) {
|
|
31
35
|
return value
|
|
32
36
|
}
|
|
33
37
|
return identityfunction(
|
|
34
38
|
vretriever.retrieve(
|
|
35
39
|
isuseless(
|
|
36
|
-
asyncUtilIdentity(stdlibIdentity(fIdentity(lodashIdentity(identityCore(value))))),
|
|
40
|
+
id(asyncUtilIdentity(stdlibIdentity(fIdentity(lodashIdentity(identityCore(value)))))),
|
|
37
41
|
falsevalue,
|
|
38
42
|
falsevalue
|
|
39
43
|
)
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@identity-js/identity",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "Returns the value passed into the function.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"identity-js"
|
|
7
7
|
],
|
|
8
|
-
"homepage": "https://github.com/
|
|
8
|
+
"homepage": "https://github.com/10xly/identityjs#readme",
|
|
9
9
|
"bugs": {
|
|
10
|
-
"url": "https://github.com/
|
|
10
|
+
"url": "https://github.com/10xly/identityjs/issues"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
14
|
+
"url": "git+https://github.com/10xly/identityjs.git"
|
|
15
15
|
},
|
|
16
16
|
"license": "Unlicense",
|
|
17
17
|
"author": "me",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@f/identity": "^1.1.1",
|
|
25
|
-
"@identity-js/number-identity": "^1.2.
|
|
25
|
+
"@identity-js/number-identity": "^1.2.3",
|
|
26
26
|
"@identity-js/string-identity": "^1.1.3",
|
|
27
27
|
"@is-(unknown)/is-finite": "^1.0.0",
|
|
28
28
|
"@is-(unknown)/is-string": "^1.0.0",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"false-value": "^2.0.1",
|
|
32
32
|
"identity-function": "^1.0.0",
|
|
33
33
|
"is-useless": "1.3.4",
|
|
34
|
+
"js-id": "^1.0.0",
|
|
34
35
|
"lodash.identity": "^3.0.0",
|
|
35
36
|
"vretriever": "^1.1.4"
|
|
36
37
|
},
|
package/test/index.js
CHANGED
|
@@ -12,6 +12,18 @@ describe('identity()', () => {
|
|
|
12
12
|
const input = 3.2
|
|
13
13
|
assert.strictEqual(identity(input), 3.2, "The function should return 3.2")
|
|
14
14
|
})
|
|
15
|
+
|
|
16
|
+
it('should return the same negative number that was passed in', () => {
|
|
17
|
+
const input = -5
|
|
18
|
+
assert.strictEqual(identity(input), -5, 'The function should return the number -5.')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should return -0 when -0 is passed in', () => {
|
|
22
|
+
const input = -0
|
|
23
|
+
const result = identity(input)
|
|
24
|
+
assert.strictEqual(result, -0, 'The function should return -0.')
|
|
25
|
+
assert.isTrue(Object.is(result, -0), 'The function should return the exact value of -0.')
|
|
26
|
+
})
|
|
15
27
|
|
|
16
28
|
it('should return the same string that was passed in', () => {
|
|
17
29
|
const input = 'hello world'
|