diff --git a/.editorconfig b/.editorconfig index 0fd4d6c..13e9c39 100644 --- a/.editorconfig +++ b/.editorconfig @@ -179,3 +179,8 @@ indent_size = 2 [*.gypi] indent_style = space indent_size = 2 + +# Set properties for citation files: +[*.{cff,cff.txt}] +indent_style = space +indent_size = 2 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6baba84..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T01:31:45.832Z diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml index 952a131..b61e587 100644 --- a/.github/workflows/productionize.yml +++ b/.github/workflows/productionize.yml @@ -81,21 +81,6 @@ jobs: id: transform-error-messages uses: stdlib-js/transform-errors-action@main - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - name: 'Update dependencies in package.json' run: | diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..2ec6fff --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,30 @@ +cff-version: 1.2.0 +title: stdlib +message: >- + If you use this software, please cite it using the + metadata from this file. + +type: software + +authors: + - name: The Stdlib Authors + url: https://github.com/stdlib-js/stdlib/graphs/contributors + +repository-code: https://github.com/stdlib-js/stdlib +url: https://stdlib.io + +abstract: | + Standard library for JavaScript and Node.js. + +keywords: + - JavaScript + - Node.js + - TypeScript + - standard library + - scientific computing + - numerical computing + - statistical computing + +license: Apache-2.0 AND BSL-1.0 + +date-released: 2016 diff --git a/README.md b/README.md index 65bd507..40a8dde 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,17 @@ limitations under the License. --> + +
+ + About stdlib... + +

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

+

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

+

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

+

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

+
+ # Convert Path [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] @@ -288,8 +299,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [npm-image]: http://img.shields.io/npm/v/@stdlib/utils-convert-path.svg [npm-url]: https://npmjs.org/package/@stdlib/utils-convert-path -[test-image]: https://github.com/stdlib-js/utils-convert-path/actions/workflows/test.yml/badge.svg?branch=main -[test-url]: https://github.com/stdlib-js/utils-convert-path/actions/workflows/test.yml?query=branch:main +[test-image]: https://github.com/stdlib-js/utils-convert-path/actions/workflows/test.yml/badge.svg?branch=v0.1.0 +[test-url]: https://github.com/stdlib-js/utils-convert-path/actions/workflows/test.yml?query=branch:v0.1.0 [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-convert-path/main.svg [coverage-url]: https://codecov.io/github/stdlib-js/utils-convert-path?branch=main diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..8b6a59a --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +/// +import convertPath from '../docs/types/index'; +export = convertPath; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..0349828 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,5 @@ +"use strict";var g=function(a,r){return function(){return r||a((r={exports:{}}).exports,r),r.exports}};var o=g(function(p,d){ +var c=require('@stdlib/assert-is-string/dist').isPrimitive,E=require('@stdlib/regexp-extended-length-path/dist'),l=require('@stdlib/string-base-lowercase/dist'),n=require('@stdlib/string-replace/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist'),s=/^([A-Za-z]):[\\\/]+/,v=/^\/([A-Za-z])\//;function w(a,r){var t,i,e;if(!c(a))throw new TypeError(u('1SH3F',a));if(!c(r))throw new TypeError(u('1SH39',r));if(r!=="win32"&&r!=="mixed"&&r!=="posix")throw new Error(u('1SHAx',r));if(e=a,r==="win32")return i=v.exec(e),i&&(t=i[1]+":\\",e=n(e,v,t)),n(e,"/","\\");if(E.REGEXP.test(a))throw new Error(u('1SHAy',a));return r==="mixed"?(i=v.exec(e),i?(t=i[1]+":/",e=n(e,v,t)):(i=s.exec(e),i&&(t=i[1]+":/",e=n(e,s,t))),n(e,"\\","/")):(i=s.exec(e),i&&(t="/"+l(i[1])+"/",e=n(e,s,t)),n(e,"\\","/"))}d.exports=w +});var h=o();module.exports=h; +/** @license Apache-2.0 */ +//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..dd5c96c --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../lib/main.js", "../lib/index.js"], + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar reExtendedLengthPath = require( '@stdlib/regexp-extended-length-path' );\nvar lowercase = require( '@stdlib/string-base-lowercase' );\nvar replace = require( '@stdlib/string-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar RE_WIN_DEVICE_ROOT = /^([A-Za-z]):[\\\\\\/]+/; // eslint-disable-line no-useless-escape\nvar RE_POSIX_DEVICE_ROOT =/^\\/([A-Za-z])\\//;\n\n\n// MAIN //\n\n/**\n* Converts between POSIX and Windows paths.\n*\n* @param {string} from - path to convert\n* @param {string} to - output path convention\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a string\n* @throws {RangeError} second argument must be a recognized output path convention\n* @throws {Error} cannot convert a Windows extended-length path to a non-Windows path convention\n* @returns {string} converted path\n*\n* @example\n* var p = convertPath( '/c/foo/bar/beep.c', 'win32' );\n* // returns 'c:\\foo\\bar\\beep.c'\n*\n* @example\n* var p = convertPath( '/c/foo/bar/beep.c', 'mixed' );\n* // returns 'c:/foo/bar/beep.c'\n*\n* @example\n* var p = convertPath( 'C:\\\\foo\\\\bar\\\\beep.c', 'posix' );\n* // returns '/c/foo/bar/beep.c'\n*\n* @example\n* var p = convertPath( 'C:\\\\foo\\\\bar\\\\beep.c', 'mixed' );\n* // returns 'C:/foo/bar/beep.c'\n*/\nfunction convertPath( from, to ) {\n\tvar device;\n\tvar parts;\n\tvar out;\n\tif ( !isString( from ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', from ) );\n\t}\n\tif ( !isString( to ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a string. Value: `%s`.', to ) );\n\t}\n\tif (\n\t\tto !== 'win32' &&\n\t\tto !== 'mixed' &&\n\t\tto !== 'posix'\n\t) {\n\t\tthrow new Error( format( 'invalid argument. Second argument must be a recognized output path convention. Value: `%s`.', to ) );\n\t}\n\tout = from;\n\n\t// Convert to a Windows path convention by transforming a POSIX device root (if present) and using a Windows path separator...\n\tif ( to === 'win32' ) {\n\t\tparts = RE_POSIX_DEVICE_ROOT.exec( out );\n\t\tif ( parts ) {\n\t\t\tdevice = parts[ 1 ]+':\\\\';\n\t\t\tout = replace( out, RE_POSIX_DEVICE_ROOT, device );\n\t\t}\n\t\treturn replace( out, '/', '\\\\' );\n\t}\n\t// Check for Windows extended-length paths...\n\tif ( reExtendedLengthPath.REGEXP.test( from ) ) {\n\t\tthrow new Error( format( 'invalid argument. Cannot convert Windows extended-length paths to POSIX paths. Value: `%s`.', from ) );\n\t}\n\t// Convert to a mixed path convention by combining a Windows drive letter convention with a POSIX path separator...\n\tif ( to === 'mixed' ) {\n\t\tparts = RE_POSIX_DEVICE_ROOT.exec( out );\n\t\tif ( parts ) {\n\t\t\tdevice = parts[ 1 ]+':/';\n\t\t\tout = replace( out, RE_POSIX_DEVICE_ROOT, device );\n\t\t} else {\n\t\t\tparts = RE_WIN_DEVICE_ROOT.exec( out );\n\t\t\tif ( parts ) {\n\t\t\t\tdevice = parts[ 1 ]+':/';\n\t\t\t\tout = replace( out, RE_WIN_DEVICE_ROOT, device );\n\t\t\t}\n\t\t}\n\t\treturn replace( out, '\\\\', '/' );\n\t}\n\t// Convert to a POSIX path convention by transforming a Windows device root (if present) and using a POSIX path separator...\n\tparts = RE_WIN_DEVICE_ROOT.exec( out );\n\tif ( parts ) {\n\t\tdevice = '/'+lowercase( parts[ 1 ] )+'/';\n\t\tout = replace( out, RE_WIN_DEVICE_ROOT, device );\n\t}\n\treturn replace( out, '\\\\', '/' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = convertPath;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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* Convert between POSIX and Windows paths.\n*\n* @module @stdlib/utils-convert-path\n*\n* @example\n* var convertPath = require( '@stdlib/utils-convert-path' );\n*\n* var p = convertPath( '/c/foo/bar/beep.c', 'win32' );\n* // returns 'c:\\foo\\bar\\beep.c'\n*\n* p = convertPath( '/c/foo/bar/beep.c', 'mixed' );\n* // returns 'c:/foo/bar/beep.c'\n*\n* p = convertPath( 'C:\\\\foo\\\\bar\\\\beep.c', 'posix' );\n* // returns '/c/foo/bar/beep.c'\n*\n* p = convertPath( 'C:\\\\foo\\\\bar\\\\beep.c', 'mixed' );\n* // returns 'C:/foo/bar/beep.c'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAuB,QAAS,qCAAsC,EACtEC,EAAY,QAAS,+BAAgC,EACrDC,EAAU,QAAS,wBAAyB,EAC5CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAqB,sBACrBC,EAAsB,kBAgC1B,SAASC,EAAaC,EAAMC,EAAK,CAChC,IAAIC,EACAC,EACAC,EACJ,GAAK,CAACZ,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACR,EAAUS,CAAG,EAClB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAG,CAAE,EAEvG,GACCA,IAAO,SACPA,IAAO,SACPA,IAAO,QAEP,MAAM,IAAI,MAAOL,EAAQ,8FAA+FK,CAAG,CAAE,EAK9H,GAHAG,EAAMJ,EAGDC,IAAO,QACX,OAAAE,EAAQL,EAAqB,KAAMM,CAAI,EAClCD,IACJD,EAASC,EAAO,CAAE,EAAE,MACpBC,EAAMT,EAASS,EAAKN,EAAsBI,CAAO,GAE3CP,EAASS,EAAK,IAAK,IAAK,EAGhC,GAAKX,EAAqB,OAAO,KAAMO,CAAK,EAC3C,MAAM,IAAI,MAAOJ,EAAQ,8FAA+FI,CAAK,CAAE,EAGhI,OAAKC,IAAO,SACXE,EAAQL,EAAqB,KAAMM,CAAI,EAClCD,GACJD,EAASC,EAAO,CAAE,EAAE,KACpBC,EAAMT,EAASS,EAAKN,EAAsBI,CAAO,IAEjDC,EAAQN,EAAmB,KAAMO,CAAI,EAChCD,IACJD,EAASC,EAAO,CAAE,EAAE,KACpBC,EAAMT,EAASS,EAAKP,EAAoBK,CAAO,IAG1CP,EAASS,EAAK,KAAM,GAAI,IAGhCD,EAAQN,EAAmB,KAAMO,CAAI,EAChCD,IACJD,EAAS,IAAIR,EAAWS,EAAO,CAAE,CAAE,EAAE,IACrCC,EAAMT,EAASS,EAAKP,EAAoBK,CAAO,GAEzCP,EAASS,EAAK,KAAM,GAAI,EAChC,CAKAb,EAAO,QAAUQ,IChFjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", + "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "reExtendedLengthPath", "lowercase", "replace", "format", "RE_WIN_DEVICE_ROOT", "RE_POSIX_DEVICE_ROOT", "convertPath", "from", "to", "device", "parts", "out", "main"] +} diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index 1c62463..9bec842 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -// TypeScript Version: 2.0 +// TypeScript Version: 4.1 /** * Converts between POSIX and Windows paths. diff --git a/package.json b/package.json index 14a72c8..db09170 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stdlib/utils-convert-path", - "version": "0.0.8", + "version": "0.1.0", "description": "Convert between POSIX and Windows paths.", "license": "Apache-2.0", "author": { @@ -40,24 +40,24 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-is-regexp-string": "^0.0.9", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/regexp-eol": "^0.0.7", - "@stdlib/regexp-extended-length-path": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-lowercase": "^0.1.0", - "@stdlib/string-format": "^0.0.3", + "@stdlib/assert-is-regexp-string": "^0.1.0", + "@stdlib/assert-is-string": "^0.1.0", + "@stdlib/cli-ctor": "^0.1.0", + "@stdlib/fs-read-file": "^0.1.0", + "@stdlib/process-read-stdin": "^0.1.0", + "@stdlib/regexp-eol": "^0.1.0", + "@stdlib/regexp-extended-length-path": "^0.1.0", + "@stdlib/streams-node-stdin": "^0.1.0", + "@stdlib/string-base-lowercase": "^0.2.0", + "@stdlib/string-format": "^0.1.0", "@stdlib/string-replace": "^0.0.11", - "@stdlib/utils-regexp-from-string": "^0.0.9" + "@stdlib/utils-regexp-from-string": "^0.1.0" }, "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/process-exec-path": "^0.0.7", + "@stdlib/assert-is-browser": "^0.1.0", + "@stdlib/assert-is-windows": "^0.1.0", + "@stdlib/bench": "^0.1.0", + "@stdlib/process-exec-path": "^0.1.0", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "proxyquire": "^2.0.0", "istanbul": "^0.4.1",