@stdlib/ndarray-base-dtype-resolve-str 0.2.2 → 0.3.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.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -179,7 +179,7 @@ See [LICENSE][stdlib-license].
179
179
 
180
180
  ## Copyright
181
181
 
182
- Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
182
+ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
183
183
 
184
184
  </section>
185
185
 
@@ -192,8 +192,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
192
192
  [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-dtype-resolve-str.svg
193
193
  [npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-dtype-resolve-str
194
194
 
195
- [test-image]: https://github.com/stdlib-js/ndarray-base-dtype-resolve-str/actions/workflows/test.yml/badge.svg?branch=v0.2.2
196
- [test-url]: https://github.com/stdlib-js/ndarray-base-dtype-resolve-str/actions/workflows/test.yml?query=branch:v0.2.2
195
+ [test-image]: https://github.com/stdlib-js/ndarray-base-dtype-resolve-str/actions/workflows/test.yml/badge.svg?branch=v0.3.0
196
+ [test-url]: https://github.com/stdlib-js/ndarray-base-dtype-resolve-str/actions/workflows/test.yml?query=branch:v0.3.0
197
197
 
198
198
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-dtype-resolve-str/main.svg
199
199
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-dtype-resolve-str?branch=main
@@ -205,8 +205,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
205
205
 
206
206
  -->
207
207
 
208
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
209
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
208
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
209
+ [chat-url]: https://stdlib.zulipchat.com
210
210
 
211
211
  [stdlib]: https://github.com/stdlib-js/stdlib
212
212
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var n=t(function(v,u){
2
- var i=require('@stdlib/ndarray-base-dtype-enum2str/dist'),s=require('@stdlib/ndarray-base-dtype-str2enum/dist');function l(e){var r=typeof e;return r==="string"?s(e)===null?null:e:r==="number"?i(e):null}u.exports=l
1
+ "use strict";var t=function(r,u){return function(){return u||r((u={exports:{}}).exports,u),u.exports}};var n=t(function(f,e){
2
+ var i=require('@stdlib/assert-is-struct-constructor-like/dist'),s=require('@stdlib/ndarray-base-dtype-enum2str/dist'),o=require('@stdlib/ndarray-base-dtype-str2enum/dist');function l(r){var u=typeof r;return u==="string"?o(r)===null?null:r:u==="number"?s(r):u==="object"&&r?String(r):i(r)?r.layout:null}e.exports=l
3
3
  });var a=n();module.exports=a;
4
4
  /** @license Apache-2.0 */
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar enum2str = require( '@stdlib/ndarray-base-dtype-enum2str' );\nvar str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );\n\n\n// MAIN //\n\n/**\n* Returns the data type string associated with a supported ndarray data type value.\n*\n* @param {*} dtype - data type value\n* @returns {(string|null)} data type string or null\n*\n* @example\n* var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );\n*\n* var v = resolve( str2enum( 'float64' ) );\n* // returns 'float64'\n*/\nfunction resolve( dtype ) {\n\tvar t = ( typeof dtype );\n\tif ( t === 'string' ) {\n\t\treturn ( str2enum( dtype ) === null ) ? null : dtype;\n\t}\n\tif ( t === 'number' ) {\n\t\treturn enum2str( dtype );\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = resolve;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return the data type string associated with a supported ndarray data type value.\n*\n* @module @stdlib/ndarray-base-dtype-resolve-str\n*\n* @example\n* var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );\n* var resolve = require( '@stdlib/ndarray-base-dtype-resolve-str' );\n*\n* var v = resolve( str2enum( 'float64' ) );\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,qCAAsC,EAC1DC,EAAW,QAAS,qCAAsC,EAiB9D,SAASC,EAASC,EAAQ,CACzB,IAAIC,EAAM,OAAOD,EACjB,OAAKC,IAAM,SACDH,EAAUE,CAAM,IAAM,KAAS,KAAOA,EAE3CC,IAAM,SACHJ,EAAUG,CAAM,EAEjB,IACR,CAKAJ,EAAO,QAAUG,ICnBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_main", "__commonJSMin", "exports", "module", "enum2str", "str2enum", "resolve", "dtype", "t", "main"]
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar enum2str = require( '@stdlib/ndarray-base-dtype-enum2str' );\nvar str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );\n\n\n// MAIN //\n\n/**\n* Returns the data type string associated with a supported ndarray data type value.\n*\n* @param {*} dtype - data type value\n* @returns {(string|null)} data type string or null\n*\n* @example\n* var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );\n*\n* var v = resolve( str2enum( 'float64' ) );\n* // returns 'float64'\n*/\nfunction resolve( dtype ) {\n\tvar t = ( typeof dtype );\n\tif ( t === 'string' ) {\n\t\treturn ( str2enum( dtype ) === null ) ? null : dtype;\n\t}\n\tif ( t === 'number' ) {\n\t\treturn enum2str( dtype );\n\t}\n\tif ( t === 'object' && dtype ) {\n\t\treturn String( dtype );\n\t}\n\tif ( isStructConstructorLike( dtype ) ) {\n\t\treturn dtype.layout;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = resolve;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return the data type string associated with a supported ndarray data type value.\n*\n* @module @stdlib/ndarray-base-dtype-resolve-str\n*\n* @example\n* var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );\n* var resolve = require( '@stdlib/ndarray-base-dtype-resolve-str' );\n*\n* var v = resolve( str2enum( 'float64' ) );\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAA0B,QAAS,2CAA4C,EAC/EC,EAAW,QAAS,qCAAsC,EAC1DC,EAAW,QAAS,qCAAsC,EAiB9D,SAASC,EAASC,EAAQ,CACzB,IAAIC,EAAM,OAAOD,EACjB,OAAKC,IAAM,SACDH,EAAUE,CAAM,IAAM,KAAS,KAAOA,EAE3CC,IAAM,SACHJ,EAAUG,CAAM,EAEnBC,IAAM,UAAYD,EACf,OAAQA,CAAM,EAEjBJ,EAAyBI,CAAM,EAC5BA,EAAM,OAEP,IACR,CAKAL,EAAO,QAAUI,IC1BjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isStructConstructorLike", "enum2str", "str2enum", "resolve", "dtype", "t", "main"]
7
7
  }
package/lib/main.js CHANGED
@@ -20,6 +20,7 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
+ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );
23
24
  var enum2str = require( '@stdlib/ndarray-base-dtype-enum2str' );
24
25
  var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );
25
26
 
@@ -46,6 +47,12 @@ function resolve( dtype ) {
46
47
  if ( t === 'number' ) {
47
48
  return enum2str( dtype );
48
49
  }
50
+ if ( t === 'object' && dtype ) {
51
+ return String( dtype );
52
+ }
53
+ if ( isStructConstructorLike( dtype ) ) {
54
+ return dtype.layout;
55
+ }
49
56
  return null;
50
57
  }
51
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-dtype-resolve-str",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Return the data type string associated with a supported ndarray data type value.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,8 +30,9 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/ndarray-base-dtype-enum2str": "^0.2.1",
34
- "@stdlib/ndarray-base-dtype-str2enum": "^0.2.1"
33
+ "@stdlib/assert-is-struct-constructor-like": "^0.1.0",
34
+ "@stdlib/ndarray-base-dtype-enum2str": "^0.2.2",
35
+ "@stdlib/ndarray-base-dtype-str2enum": "^0.2.2"
35
36
  },
36
37
  "devDependencies": {},
37
38
  "engines": {
@@ -65,7 +66,6 @@
65
66
  "util",
66
67
  "enum"
67
68
  ],
68
- "__stdlib__": {},
69
69
  "funding": {
70
70
  "type": "opencollective",
71
71
  "url": "https://opencollective.com/stdlib"