feat(napi-derive): support const export

This commit is contained in:
LongYinan 2021-11-10 19:04:36 +08:00
parent 6bfaaebadc
commit 47da28adb4
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
12 changed files with 113 additions and 5 deletions

View file

@ -8,7 +8,8 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`export function getWords(): Array<string>
`export const DEFAULT_COST: number␊
export function getWords(): Array<string>
export function getNums(): Array<number>
export function sumNums(nums: Array<number>): number␊
export function readFileAsync(path: string): Promise<Buffer>

View file

@ -3,6 +3,7 @@ import { join } from 'path'
import test from 'ava'
import {
DEFAULT_COST,
add,
fibonacci,
contains,
@ -48,6 +49,10 @@ import {
createSymbol,
} from '../'
test('export const', (t) => {
t.is(DEFAULT_COST, 12)
})
test('number', (t) => {
t.is(add(1, 2), 3)
t.is(fibonacci(5), 5)

View file

@ -1,3 +1,4 @@
export const DEFAULT_COST: number
export function getWords(): Array<string>
export function getNums(): Array<number>
export function sumNums(nums: Array<number>): number

View file

@ -3,6 +3,9 @@ extern crate napi_derive;
#[macro_use]
extern crate serde_derive;
#[napi]
pub const DEFAULT_COST: u32 = 12;
mod array;
mod r#async;
mod bigint;