Skip to content

Commit

Permalink
Add TypeScript definition file
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Jan 15, 2019
1 parent 4b8e0fa commit 001bfff
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 2.0

/**
* Computes the natural logarithm of \\( 1-\exp(-|x|) \\).

This comment has been minimized.

Copy link
@Planeshifter

Planeshifter Jan 15, 2019

Author Member

@athan Shall we avoid including LaTeX equations, as these won't render and I am doubting that editors like VSCode will ever include something like MathJax or KaTeX?

This comment has been minimized.

Copy link
@kgryte

kgryte Jan 15, 2019

Member

Yeah, we don't have any reason...or do we...we do if we ever decided to generate web based TS docs.

This comment has been minimized.

Copy link
@kgryte

kgryte Jan 15, 2019

Member

I am not sure the best approach here. Would MathML be better? Can you test if MathML renders in VS Code popups?

This comment has been minimized.

Copy link
@kgryte

kgryte Jan 15, 2019

Member

Reasoning: since TSDoc comments can be Markdown and HTML in Markdown is valid, maybe MathML will render.

This comment has been minimized.

Copy link
@Planeshifter

Planeshifter Jan 15, 2019

Author Member

MathML doesn't render, it seems.

This comment has been minimized.

Copy link
@kgryte

kgryte Jan 15, 2019

Member

VSCode apparently escapes all HTML (microsoft/vscode#40607) and this is not likely to be allowed anytime soon.

This comment has been minimized.

Copy link
@kgryte

kgryte Jan 16, 2019

Member

I suppose, if we can render in Unicode, we should opt for Unicode. Otherwise, plain text will have to suffice, even if we render via TSDoc web. Not sure we have any other choice atm.

This comment has been minimized.

Copy link
@Planeshifter

Planeshifter Jan 16, 2019

Author Member

Sounds good. In this case, 1-exp(-|x|) doesn't look too bad.

This comment has been minimized.

Copy link
@kgryte

kgryte Jan 16, 2019

Member

Yeah, it is good enough.

*
* @param x - input value
* @returns function value
*
* @example
* var v = log1mexp( 1.1 );
* // returns ~-0.40477
*
* @example
* var v = log1mexp( 0.0 );
* // returns -Infinity
*
* @example
* var v = log1mexp( NaN );
* // returns NaN
*/
declare function log1mexp( x: number ): number;


// EXPORTS //

export = log1mexp;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import log1mexp = require( './index' );


// TESTS //

// The function returns a number...
{
log1mexp( 8 ); // $ExpectType number
}

// The function does not compile if provided a value other than an a number...
{
log1mexp( true ); // $ExpectError
log1mexp( false ); // $ExpectError
log1mexp( '5' ); // $ExpectError
log1mexp( [] ); // $ExpectError
log1mexp( {} ); // $ExpectError
log1mexp( ( x ) => x ); // $ExpectError
}

// The function does not compile if provided insufficient arguments...
{
log1mexp(); // $ExpectError
}


log1mexp( )
12 changes: 12 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/log1mexp/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ var NINF = require( '@stdlib/constants/math/float64-ninf' );
*
* @param {number} x - input value
* @returns {number} function value
*
* @example
* var v = log1mexp( 1.1 );
* // returns ~-0.40477
*
* @example
* var v = log1mexp( 0.0 );
* // returns -Infinity
*
* @example
* var v = log1mexp( NaN );
* // returns NaN
*/
function log1mexp( x ) {
var ax;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test": "./test"
},
"scripts": {},
"types": "./docs/types",
"homepage": "https://github.com/stdlib-js/stdlib",
"repository": {
"type": "git",
Expand Down

0 comments on commit 001bfff

Please sign in to comment.