Skip to content

Function: changeExt()

ts
function changeExt(path, extension): string;

Replaces the extension of a path.

Parameters

ParameterTypeDescription
pathstringThe source path.
extensionstringThe new extension, with or without a leading dot.

Returns

string

The path with the replaced extension.

Example

ts
changeExt('foo.ts', '.js')
// => 'foo.js'

Since

1.0.0

Released under the MIT License.