@ohos-ports/stdlib-symbol 0.0.0-stage → 0.4.1-beta.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 (56) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +1 -0
  3. package/README.md +205 -2
  4. package/SECURITY.md +5 -0
  5. package/async-iterator/README.md +129 -0
  6. package/async-iterator/docs/repl.txt +16 -0
  7. package/async-iterator/docs/types/index.d.ts +31 -0
  8. package/async-iterator/docs/types/test.ts +29 -0
  9. package/async-iterator/lib/index.js +43 -0
  10. package/async-iterator/lib/main.js +48 -0
  11. package/async-iterator/package.json +61 -0
  12. package/ctor/README.md +143 -0
  13. package/ctor/docs/repl.txt +27 -0
  14. package/ctor/docs/types/index.d.ts +34 -0
  15. package/ctor/docs/types/test.ts +34 -0
  16. package/ctor/lib/index.js +40 -0
  17. package/ctor/lib/main.js +28 -0
  18. package/ctor/package.json +60 -0
  19. package/docs/types/index.d.ts +116 -0
  20. package/has-instance/README.md +143 -0
  21. package/has-instance/docs/repl.txt +18 -0
  22. package/has-instance/docs/types/index.d.ts +31 -0
  23. package/has-instance/docs/types/test.ts +29 -0
  24. package/has-instance/lib/index.js +49 -0
  25. package/has-instance/lib/main.js +54 -0
  26. package/has-instance/package.json +57 -0
  27. package/is-concat-spreadable/README.md +122 -0
  28. package/is-concat-spreadable/docs/repl.txt +18 -0
  29. package/is-concat-spreadable/docs/types/index.d.ts +31 -0
  30. package/is-concat-spreadable/docs/types/test.ts +29 -0
  31. package/is-concat-spreadable/lib/index.js +46 -0
  32. package/is-concat-spreadable/lib/main.js +50 -0
  33. package/is-concat-spreadable/package.json +58 -0
  34. package/iterator/README.md +164 -0
  35. package/iterator/docs/repl.txt +16 -0
  36. package/iterator/docs/types/index.d.ts +31 -0
  37. package/iterator/docs/types/test.ts +29 -0
  38. package/iterator/lib/index.js +75 -0
  39. package/iterator/lib/main.js +79 -0
  40. package/iterator/package.json +58 -0
  41. package/lib/index.js +105 -0
  42. package/package.json +58 -4
  43. package/replace/README.md +130 -0
  44. package/replace/docs/repl.txt +18 -0
  45. package/replace/docs/types/index.d.ts +31 -0
  46. package/replace/docs/types/test.ts +29 -0
  47. package/replace/lib/index.js +44 -0
  48. package/replace/lib/main.js +48 -0
  49. package/replace/package.json +58 -0
  50. package/to-primitive/README.md +158 -0
  51. package/to-primitive/docs/repl.txt +16 -0
  52. package/to-primitive/docs/types/index.d.ts +30 -0
  53. package/to-primitive/docs/types/test.ts +29 -0
  54. package/to-primitive/lib/index.js +57 -0
  55. package/to-primitive/lib/main.js +63 -0
  56. package/to-primitive/package.json +61 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var hasToPrimitiveSymbolSupport = require( '@ohos-ports/stdlib-assert/has-to-primitive-symbol-support' ); // eslint-disable-line id-length
24
+ var Symbol = require( './../../ctor' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Symbol which specifies a method for converting an object to a primitive value.
31
+ *
32
+ * @constant
33
+ * @type {(symbol|null)}
34
+ * @default
35
+ *
36
+ * @example
37
+ * var Number = require( '@stdlib/number/ctor' );
38
+ *
39
+ * function valueOf( hint ) {
40
+ * if ( hint === 'string' ) {
41
+ * return 'MyObject';
42
+ * }
43
+ * if ( hint === 'number' ) {
44
+ * return 42;
45
+ * }
46
+ * return null;
47
+ * }
48
+ *
49
+ * var obj = {};
50
+ * obj[ ToPrimitiveSymbol ] = valueOf;
51
+ *
52
+ * var str = String( obj );
53
+ * // returns 'MyObject'
54
+ *
55
+ * var num = Number( obj );
56
+ * // returns 42
57
+ */
58
+ var ToPrimitiveSymbol = ( hasToPrimitiveSymbolSupport() ) ? Symbol.toPrimitive : null; // eslint-disable-line max-len
59
+
60
+
61
+ // EXPORTS //
62
+
63
+ module.exports = ToPrimitiveSymbol;
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@stdlib/symbol/to-primitive",
3
+ "version": "0.0.0",
4
+ "description": "Symbol which specifies a method for converting an object to a primitive value.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "directories": {
18
+ "doc": "./docs",
19
+ "example": "./examples",
20
+ "lib": "./lib",
21
+ "test": "./test"
22
+ },
23
+ "types": "./docs/types",
24
+ "scripts": {},
25
+ "homepage": "https://github.com/stdlib-js/stdlib",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git://github.com/stdlib-js/stdlib.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/stdlib-js/stdlib/issues"
32
+ },
33
+ "dependencies": {},
34
+ "devDependencies": {},
35
+ "engines": {
36
+ "node": ">=0.10.0",
37
+ "npm": ">2.7.0"
38
+ },
39
+ "os": [
40
+ "aix",
41
+ "darwin",
42
+ "freebsd",
43
+ "linux",
44
+ "macos",
45
+ "openbsd",
46
+ "sunos",
47
+ "win32",
48
+ "windows"
49
+ ],
50
+ "keywords": [
51
+ "stdlib",
52
+ "symbol",
53
+ "sym",
54
+ "primitive",
55
+ "conversion",
56
+ "coercion",
57
+ "type",
58
+ "toprimitive",
59
+ "to-primitive"
60
+ ]
61
+ }