rename "ParseOptions.asMemoryView" to "ParseOptions.bytes"

This commit is contained in:
Rasmus Andersson 2020-10-16 16:02:28 -07:00
parent 6564eb12cc
commit b407df075e
8 changed files with 13 additions and 11 deletions

2
dist/markdown.es.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/markdown.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

10
markdown.d.ts vendored
View file

@ -2,8 +2,8 @@
* parse reads markdown source at s and converts it to HTML. * parse reads markdown source at s and converts it to HTML.
* When output is a byte array, it will be a reference. * When output is a byte array, it will be a reference.
*/ */
export function parse(s :Source, o? :ParseOptions & { asMemoryView? :never|false }) :string export function parse(s :Source, o? :ParseOptions & { bytes? :never|false }) :string
export function parse(s :Source, o? :ParseOptions & { asMemoryView :true }) :Uint8Array export function parse(s :Source, o? :ParseOptions & { bytes :true }) :Uint8Array
/** Markdown source code can be provided as a JavaScript string or UTF8 encoded data */ /** Markdown source code can be provided as a JavaScript string or UTF8 encoded data */
type Source = string | ArrayLike<number> type Source = string | ArrayLike<number>
@ -17,8 +17,7 @@ export interface ParseOptions {
format? : "html" | "xhtml" format? : "html" | "xhtml"
/** /**
* asMemoryView=true causes parse() to return a view of heap memory as a Uint8Array, * bytes=true causes parse() to return the result as a Uint8Array instead of a string.
* instead of a string.
* *
* The returned Uint8Array is only valid until the next call to parse(). * The returned Uint8Array is only valid until the next call to parse().
* If you need to keep the returned data around, call Uint8Array.slice() to make a copy, * If you need to keep the returned data around, call Uint8Array.slice() to make a copy,
@ -27,6 +26,9 @@ export interface ParseOptions {
* This only provides a performance benefit when you never need to convert the output * This only provides a performance benefit when you never need to convert the output
* to a string. In most cases you're better off leaving this unset or false. * to a string. In most cases you're better off leaving this unset or false.
*/ */
bytes? :boolean
/** @depreceated use "bytes" instead (v1.1.1) */
asMemoryView? :boolean asMemoryView? :boolean
} }

View file

@ -79,7 +79,7 @@ export function parse(source, options) {
// console.log(utf8.decode(outbuf)) // console.log(utf8.decode(outbuf))
// } // }
if (options.asMemoryView) { if (options.bytes || options.asMemoryView) {
return outbuf return outbuf
} }
return utf8.decode(outbuf) return utf8.decode(outbuf)