Implement RFC-391 (#18585)

This commit is contained in:
Juan Carlos 2021-08-22 16:32:55 -03:00 • committed by GitHub
commit e65dc36ddd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 91 deletions

View file

@ -1,9 +1,8 @@
## - Fetch for the JavaScript target: https://developer.mozilla.org/docs/Web/API/Fetch_API ## - Fetch for the JavaScript target: https://developer.mozilla.org/docs/Web/API/Fetch_API
## .. Note:: jsfetch is Experimental. jsfetch module requires `-d:nimExperimentalJsfetch` ## .. Note:: jsfetch is Experimental.
when not defined(js): when not defined(js):
{.fatal: "Module jsfetch is designed to be used with the JavaScript backend.".} {.fatal: "Module jsfetch is designed to be used with the JavaScript backend.".}
when defined(nimExperimentalJsfetch):
import std/[asyncjs, jsheaders, jsformdata] import std/[asyncjs, jsheaders, jsformdata]
from std/httpcore import HttpMethod from std/httpcore import HttpMethod
from std/jsffi import JsObject from std/jsffi import JsObject
@ -115,7 +114,7 @@ when defined(nimExperimentalJsfetch):
func `$`*(self: Request | Response | Body | FetchOptions): string = $toCstring(self) func `$`*(self: Request | Response | Body | FetchOptions): string = $toCstring(self)
runnableExamples("-d:nimExperimentalJsfetch -r:off"): runnableExamples("-r:off"):
import std/[asyncjs, jsconsole, jsheaders, jsformdata] import std/[asyncjs, jsconsole, jsheaders, jsformdata]
from std/httpcore import HttpMethod from std/httpcore import HttpMethod
from std/jsffi import JsObject from std/jsffi import JsObject

View file

@ -33,7 +33,6 @@ hint("Processing", off)
# experimental API's are enabled in testament, refs https://github.com/timotheecour/Nim/issues/575 # experimental API's are enabled in testament, refs https://github.com/timotheecour/Nim/issues/575
# sync with `kochdocs.docDefines` or refactor. # sync with `kochdocs.docDefines` or refactor.
switch("define", "nimExperimentalAsyncjsThen") switch("define", "nimExperimentalAsyncjsThen")
switch("define", "nimExperimentalJsfetch")
switch("define", "nimExperimentalLinenoiseExtra") switch("define", "nimExperimentalLinenoiseExtra")
switch("define", "nimPreviewFloatRoundtrip") switch("define", "nimPreviewFloatRoundtrip")

View file

@ -8,7 +8,7 @@ const
gaCode* = " --doc.googleAnalytics:UA-48159761-1" gaCode* = " --doc.googleAnalytics:UA-48159761-1"
# errormax: subsequent errors are probably consequences of 1st one; a simple # errormax: subsequent errors are probably consequences of 1st one; a simple
# bug could cause unlimited number of errors otherwise, hard to debug in CI. # bug could cause unlimited number of errors otherwise, hard to debug in CI.
docDefines = "-d:nimExperimentalAsyncjsThen -d:nimExperimentalJsfetch -d:nimExperimentalLinenoiseExtra" docDefines = "-d:nimExperimentalAsyncjsThen -d:nimExperimentalLinenoiseExtra"
nimArgs = "--errormax:3 --hint:Conf:off --hint:Path:off --hint:Processing:off --hint:XDeclaredButNotUsed:off --warning:UnusedImport:off -d:boot --putenv:nimversion=$# $#" % [system.NimVersion, docDefines] nimArgs = "--errormax:3 --hint:Conf:off --hint:Path:off --hint:Processing:off --hint:XDeclaredButNotUsed:off --warning:UnusedImport:off -d:boot --putenv:nimversion=$# $#" % [system.NimVersion, docDefines]
gitUrl = "https://github.com/nim-lang/Nim" gitUrl = "https://github.com/nim-lang/Nim"
docHtmlOutput = "doc/html" docHtmlOutput = "doc/html"