* Add jsconsole.dir * Update lib/js/jsconsole.nim Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
13 KiB
v1.6.x - yyyy-mm-dd
Standard library additions and changes
-
Make custom op in macros.quote work for all statements.
-
On Windows the SSL library now checks for valid certificates. It uses the
cacert.pemfile for this purpose which was extracted fromhttps://curl.se/ca/cacert.pem. Besides the OpenSSL DLLs (e.g. libssl-1_1-x64.dll, libcrypto-1_1-x64.dll) you now also need to shipcacert.pemwith your.exefile. -
Make
{.requiresInit.}pragma to work fordistincttypes. -
Added a macros
enumLenfor returning the number of items in an enum to thetypetraits.nimmodule. -
preludenow works with the JavaScript target. Addedsequtilsimport toprelude.preludecan now be used viainclude std/prelude, butinclude preludestill works. -
Added
almostEqualinmathfor comparing two float values using a machine epsilon. -
Added
clampinmathwhich allows using aSliceto clamp to a value. -
The JSON module can now handle integer literals and floating point literals of arbitrary length and precision. Numbers that do not fit the underlying
BiggestIntorBiggestFloatfields are kept as string literals and one can use external BigNum libraries to handle these. TheparseFloatfamily of functions also has now optionalrawIntegersandrawFloatsparameters that can be used to enforce that all integer or float literals remain in the "raw" string form so that client code can easily treat small and large numbers uniformly. -
Added
BackwardsIndexoverload forJsonNode. -
added
jsonutils.jsonTooverload withopt = Joptions()param. -
json.%,json.to,jsonutils.formJson,jsonutils.toJsonnow work withuint|uint64instead of raising (as in 1.4) or giving wrong results (as in 1.2). -
Added an overload for the
collectmacro that inferes the container type based on the syntax of the last expression. Works with std seqs, tables and sets. -
Added
randStatetemplate that exposes the default random number generator. Useful for library authors. -
Added
std/enumutilsmodule. AddedgenEnumCaseStmtmacro that generates case statement to parse string to enum. Addeditemsfor enums with holes. AddedsymbolNameto return the enum symbol name ignoring the human readable name. -
Added
typetraits.HoleyEnumfor enums with holes,OrdinalEnumfor enums without holes. -
Removed deprecated
iupmodule from stdlib, it has already moved to nimble. -
various functions in
httpclientnow accepturlof typeUri. Moreoverrequestfunction'shttpMethodargument of typestringwas deprecated in favor ofHttpMethodenum type. -
nodejsbackend now supports osenv:getEnv,putEnv,envPairs,delEnv,existsEnv. -
Added
cmpMemtosystem. -
doAssertRaisesnow correctly handles foreign exceptions. -
Added
asyncdispatch.activeDescriptorsthat returns the number of currently active async event handles/file descriptors. -
--gc:orcis now 10% faster than previously for common workloads. If you have trouble with its changed behavior, compile with-d:nimOldOrc. -
os.FileInfo(returned bygetFileInfo) now containsblockSize, determining preferred I/O block size for this file object. -
Added a simpler to use
io.readCharsoverload. -
reprnow doesn't insert trailing newline; previous behavior was very inconsistent, see #16034. Use-d:nimLegacyReprWithNewlinefor previous behavior. -
Added
**to jsffi. -
writeStackTraceis available in JS backend now. -
Added
decodeQuerytostd/uri. -
strscans.scanfnow supports parsing single characters. -
strscans.scanTupleadded which usesstrscans.scanfinternally, returning a tuple which can be unpacked for easier usage ofscanf. -
Added
setutils.toSetthat can take any iterable and convert it to a built-inset, if the iterable yields a built-in settable type. -
Added
setutils.fullSetwhich returns a full built-insetfor a valid type. -
Added
setutils.complementwhich returns the complement of a built-inset. -
Added
setutils.[]=. -
Added
math.isNaN. -
echoanddebugEchowill now raiseIOErrorif writing to stdout fails. Previous behavior silently ignored errors. See #16366. Use-d:nimLegacyEchoNoRaisefor previous behavior. -
Added
jsbigintsmodule, arbitrary precision integers for JavaScript target. -
Added
math.copySign. -
Added new operations for singly- and doubly linked lists:
lists.toSinglyLinkedListandlists.toDoublyLinkedListconvert fromopenArrays;lists.copyimplements shallow copying;lists.addconcatenates two lists - an O(1) variation that consumes its argument,addMoved, is also supplied. -
Added
euclDivandeuclModtomath. -
Added
httpcore.is1xxand missing HTTP codes. -
Added
jsconsole.jsAssertfor JavaScript target. -
Added
posix_utils.osReleaseFileto get system identification fromos-releasefile on Linux and the BSDs. https://www.freedesktop.org/software/systemd/man/os-release.html -
math.roundnow is rounded "away from zero" in JS backend which is consistent with other backends. See #9125. Use-d:nimLegacyJsRoundfor previous behavior. -
Added
socketstreammodule that wraps sockets in the stream interface -
Changed the behavior of
uri.decodeQuerywhen there are unencoded=characters in the decoded values. Prior versions would raise an error. This is no longer the case to comply with the HTML spec and other languages implementations. Old behavior can be obtained with-d:nimLegacyParseQueryStrict.cgi.decodeDatawhich uses the same underlying code is also updated the same way. -
Added
sugar.dumpToStringwhich improves onsugar.dump. -
Added
math.signbit. -
Removed the optional
longestMatchparameter of thecritbits._WithPrefixiterators (it never worked reliably) -
In
lists: renamedappendtoaddand retainedappendas an alias; addedprependandprependMovedanalogously toaddandaddMoved; addedremoveforSinglyLinkedLists. -
Deprecated
any. See https://github.com/nim-lang/RFCs/issues/281 -
Added
std/sysrandmodule to get random numbers from a secure source provided by the operating system. -
Added optional
optionsargument tocopyFile,copyFileToDir, andcopyFileWithPermissions. By default, on non-Windows OSes, symlinks are followed (copy files symlinks point to); on Windows,optionsargument is ignored and symlinks are skipped. -
On non-Windows OSes,
copyDirandcopyDirWithPermissionscopy symlinks as symlinks (instead of skipping them as it was before); on Windows symlinks are skipped. -
On non-Windows OSes,
moveFileandmoveDirmove symlinks as symlinks (instead of skipping them sometimes as it was before). -
Added optional
followSymlinksargument tosetFilePermissions. -
Added
os.isAdminto tell whether the caller's process is a member of the Administrators local group (on Windows) or a root (on POSIX). -
Added
random.initRand()overload with no argument which uses the current time as a seed. -
Added experimental
linenoise.readLineStatusto get line and status (e.g. ctrl-D or ctrl-C). -
Added
compilesettings.SingleValueSetting.libPath. -
std/wrapnilsdoesn't useexperimental:dotOperatorsanymore, avoiding issues like https://github.com/nim-lang/Nim/issues/13063 (which affected error messages) for modules importingstd/wrapnils. Added??.macro which returns anOption. -
Added
math.frexpoverload procs. Deprecatedc_frexp, usefrexpinstead. -
parseopt.initOptParserhas been made available andparseopthas been added back topreludefor all backends. PreviouslyinitOptParserwas unavailable if theosmodule did not haveparamCountorparamStr, but the use of these ininitOptParserwere conditionally to the runtime arguments passed to it, soinitOptParserhas been changed to raiseValueErrorwhen the real command line is not available.parseoptwas previously excluded frompreludefor JS, as it could not be imported. -
On POSIX systems, the default signal handlers used for Nim programs (it's used for printing the stacktrace on fatal signals) will now re-raise the signal for the OS default handlers to handle.
This lets the OS perform its default actions, which might include core dumping (on select signals) and notifying the parent process about the cause of termination.
-
Added
system.prepareStrMutationfor better support of low levelmoveMem,copyMemoperations for Orc's copy-on-write string implementation. -
hashes.hashnow supportsobject, but can be overloaded. -
Added
std/strbasicsfor high performance string operations. Addedstrip,setSlice,add(a: var string, b: openArray[char]). -
hashes.hashnow supportsobject, but can be overloaded. -
Added to
wrapnilsan option-like API via??.,isSome,get. -
std/optionschanged$some(3)to"some(3)"instead of"Some(3)"and$none(int)to"none(int)"instead of"None[int]". -
Added
std/jsfetchmodule Fetch wrapper for JavaScript target. -
Added
std/jsheadersmodule Headers wrapper for JavaScript target. -
Added
std/jsformdatamodule FormData wrapper for JavaScript target. -
system.addEscapedCharnow renders\ras\rinstead of\c, to be compatible with most other languages. -
Removed support for named procs in
sugar.=>. -
Added
jscore.debuggerto call any available debugging functionality, such as breakpoints.. -
Added
std/channels. -
Added
htmlgen.portalfor making "SPA style" pages using HTML only. -
Added
ZZZandZZZZpatterns totimes.nimDateTimeparsing, to match time zone offsets without colons, e.g.UTC+7 -> +0700. -
In
std/os,getHomeDir,expandTilde,getTempDir,getConfigDirnow do not include trailingDirSep, unless-d:nimLegacyHomeDiris specified (for a transition period). -
Added
jsconsole.dir,jsconsole.dirxml,jsconsole.timeStamp.
Language changes
-
nimscriptnow handlesexcept Exception as e. -
The
cstringdoesn't support[]=operator in JS backend. -
nil dereference is not allowed at compile time.
cast[ptr int](nil)[]is rejected at compile time. -
typetraits.distinctBasenow is identity instead of error for non distinct types. -
os.copyFileis now 2.5x faster on OSX, by usingcopyfilefromcopyfile.h; use-d:nimLegacyCopyFilefor OSX < 10.5. -
The required name of case statement macros for the experimental
caseStmtMacrosfeature has changed frommatchto`case`. -
typedesc[Foo]now renders as such instead oftype Fooin compiler messages.
Compiler changes
-
Added
--declaredlocsto show symbol declaration location in messages. -
Deprecated
TaintedStringand--taintmode. -
Deprecated
--nilseqswhich is now a noop. -
Added
--spellSuggestto show spelling suggestions on typos. -
Source+Edit links now appear on top of every docgen'd page when
nim doc --git.url:url ...is given. -
Added
nim --eval:cmdto evaluate a command directly, seenim --help. -
VM now supports
addr(mystring[ind])(index + index assignment) -
Type mismatch errors now show more context, use
-d:nimLegacyTypeMismatchfor previous behavior. -
Added
--hintAsErrorwith similar semantics as--warningAsError. -
TLS: OSX now uses native TLS (
--tlsEmulation:off), TLS now works with importcpp non-POD types, such types must use.cppNonPodand--tlsEmulation:offshould be used. -
Now array literals(JS backend) uses JS typed arrays when the corresponding js typed array exists, for example
[byte(1), 2, 3]generatesnew Uint8Array([1, 2, 3]). -
docgen: rst files can now use single backticks instead of double backticks and correctly render in both rst2html (as before) as well as common tools rendering rst directly (e.g. github), by adding:
default-role:: codedirective inside the rst file, which is now handled by rst2html. -
Added
-d:nimStrictModein CI in several places to ensure code doesn't have certain hints/warnings -
Added
then,catchtoasyncjs, for now hidden behind-d:nimExperimentalAsyncjsThen. -
--newruntimeand--refchecksare deprecated. -
Added
unsafeIsolateandextracttostd/isolation.
Tool changes
-
The rst parser now supports markdown table syntax. Known limitations:
- cell alignment is not supported, i.e. alignment annotations in a delimiter
row (
:---,:--:,---:) are ignored, - every table row must start with
|, e.g.| cell 1 | cell 2 |.
- cell alignment is not supported, i.e. alignment annotations in a delimiter
row (
-
fusionis now un-bundled from nim,./koch fusionwill install it via nimble at a fixed hash.