Commit 75b6573 1 parent 44a437d commit 75b6573 Copy full SHA for 75b6573
File tree 8 files changed +112
-0
lines changed
examples/typescript.module
8 files changed +112
-0
lines changed Original file line number Diff line number Diff line change
1
+ /build
Original file line number Diff line number Diff line change
1
+ // NOTE: used for "test:alt" script only
2
+ // @see https://github.com/lukeed/loadr
3
+ export const loaders = [ 'tsm' ] ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "private" : true ,
3
+ "type" : " module" ,
4
+ "scripts" : {
5
+ "test" : " tsm node_modules/uvu/bin.js tests" ,
6
+ "test:alt" : " loadr -- uvu tests"
7
+ },
8
+ "devDependencies" : {
9
+ "loadr" : " ^0.1.1" ,
10
+ "tsm" : " ^2.0.0" ,
11
+ "uvu" : " ^0.5.1"
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } a
3
+ * @param {number } b
4
+ */
5
+ export const sum = ( a , b ) => a + b ;
6
+
7
+ /**
8
+ * @param {number } a
9
+ * @param {number } b
10
+ */
11
+ export const div = ( a , b ) => a / b ;
12
+
13
+ /**
14
+ * @param {number } a
15
+ * @param {number } b
16
+ */
17
+ export const mod = ( a , b ) => a % b ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {string } str
3
+ */
4
+ export function capitalize ( str ) {
5
+ return str [ 0 ] . toUpperCase ( ) + str . substring ( 1 ) ;
6
+ }
7
+
8
+ /**
9
+ * @param {string } str
10
+ */
11
+ export function dashify ( str ) {
12
+ return str . replace ( / ( [ a - z A - Z ] ) (? = [ A - Z \d ] ) / g, '$1-' ) . toLowerCase ( ) ;
13
+ }
Original file line number Diff line number Diff line change
1
+ import { test } from 'uvu' ;
2
+ import * as assert from 'uvu/assert' ;
3
+ import * as math from '../src/math.js' ;
4
+
5
+ test ( 'sum' , ( ) => {
6
+ assert . type ( math . sum , 'function' ) ;
7
+ assert . is ( math . sum ( 1 , 2 ) , 3 ) ;
8
+ assert . is ( math . sum ( - 1 , - 2 ) , - 3 ) ;
9
+ assert . is ( math . sum ( - 1 , 1 ) , 0 ) ;
10
+ } ) ;
11
+
12
+ test ( 'div' , ( ) => {
13
+ assert . type ( math . div , 'function' ) ;
14
+ assert . is ( math . div ( 1 , 2 ) , 0.5 ) ;
15
+ assert . is ( math . div ( - 1 , - 2 ) , 0.5 ) ;
16
+ assert . is ( math . div ( - 1 , 1 ) , - 1 ) ;
17
+ } ) ;
18
+
19
+ test ( 'mod' , ( ) => {
20
+ assert . type ( math . mod , 'function' ) ;
21
+ assert . is ( math . mod ( 1 , 2 ) , 1 ) ;
22
+ assert . is ( math . mod ( - 3 , - 2 ) , - 1 ) ;
23
+ assert . is ( math . mod ( 7 , 4 ) , 3 ) ;
24
+ } ) ;
25
+
26
+ test . run ( ) ;
Original file line number Diff line number Diff line change
1
+ import { test } from 'uvu' ;
2
+ import * as assert from 'uvu/assert' ;
3
+ import * as utils from '../src/utils.js' ;
4
+
5
+ test ( 'capitalize' , ( ) => {
6
+ assert . type ( utils . capitalize , 'function' ) ;
7
+ assert . is ( utils . capitalize ( 'hello' ) , 'Hello' ) ;
8
+ assert . is ( utils . capitalize ( 'foo bar' ) , 'Foo bar' ) ;
9
+ } ) ;
10
+
11
+ test ( 'dashify' , ( ) => {
12
+ assert . type ( utils . dashify , 'function' ) ;
13
+ assert . is ( utils . dashify ( 'fooBar' ) , 'foo-bar' ) ;
14
+ assert . is ( utils . dashify ( 'FooBar' ) , 'foo-bar' ) ;
15
+ assert . is ( utils . dashify ( 'foobar' ) , 'foobar' ) ;
16
+ } ) ;
17
+
18
+ test . run ( ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "strict" : true ,
4
+ "allowJs" : true ,
5
+ "target" : "esnext" ,
6
+ "noImplicitAny" : true ,
7
+ "moduleResolution" : "node" ,
8
+ "forceConsistentCasingInFileNames" : true ,
9
+ "alwaysStrict" : true ,
10
+ "module" : "esnext" ,
11
+ "checkJs" : true ,
12
+ "noEmit" : true
13
+ } ,
14
+ "include" : [
15
+ "src" ,
16
+ "tests"
17
+ ] ,
18
+ "exclude" : [
19
+ "node_modules"
20
+ ]
21
+ }
You can’t perform that action at this time.
0 commit comments