style fix: change 'JS' to 'js' to make it consistent (#13168)

This commit is contained in:
Miran 2020-01-16 14:14:03 +01:00 • committed by Andreas Rumpf
commit 352232e62d
14 changed files with 60 additions and 60 deletions

View file

@ -151,7 +151,7 @@ proc hash*[A](x: openArray[A]): Hash
proc hash*[A](x: set[A]): Hash
when defined(JS):
when defined(js):
proc imul(a, b: uint32): uint32 =
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
let mask = 0xffff'u32
@ -267,7 +267,7 @@ proc hash*(x: cstring): Hash =
inc i
result = !$result
else:
when not defined(JS) and defined(nimToOpenArrayCString):
when not defined(js) and defined(nimToOpenArrayCString):
murmurHash(toOpenArrayByte(x, 0, x.high))
else:
let xx = $x

View file

@ -263,7 +263,7 @@ proc cumsum*[T](x: var openArray[T]) =
for i in 1 ..< x.len: x[i] = x[i-1] + x[i]
{.push noSideEffect.}
when not defined(JS): # C
when not defined(js): # C
proc sqrt*(x: float32): float32 {.importc: "sqrtf", header: "<math.h>".}
proc sqrt*(x: float64): float64 {.importc: "sqrt", header: "<math.h>".}
## Computes the square root of ``x``.
@ -329,7 +329,7 @@ proc log*[T: SomeFloat](x, base: T): T =
## echo log(8.0, -2.0) ## nan
ln(x) / ln(base)
when not defined(JS): # C
when not defined(js): # C
proc log10*(x: float32): float32 {.importc: "log10f", header: "<math.h>".}
proc log10*(x: float64): float64 {.importc: "log10", header: "<math.h>".}
## Computes the common logarithm (base 10) of ``x``.
@ -562,7 +562,7 @@ proc arccsch*[T: float32|float64](x: T): T = arcsinh(1.0 / x)
const windowsCC89 = defined(windows) and defined(bcc)
when not defined(JS): # C
when not defined(js): # C
proc hypot*(x, y: float32): float32 {.importc: "hypotf", header: "<math.h>".}
proc hypot*(x, y: float64): float64 {.importc: "hypot", header: "<math.h>".}
## Computes the hypotenuse of a right-angle triangle with ``x`` and
@ -851,7 +851,7 @@ proc floorMod*[T: SomeNumber](x, y: T): T =
result = x mod y
if (result > 0 and y < 0) or (result < 0 and y > 0): result += y
when not defined(JS):
when not defined(js):
proc c_frexp*(x: float32, exponent: var int32): float32 {.
importc: "frexp", header: "<math.h>".}
proc c_frexp*(x: float64, exponent: var int32): float64 {.
@ -1104,7 +1104,7 @@ proc lcm*[T](x: openArray[T]): T {.since: (1, 1).} =
result = lcm(result, x[i])
inc(i)
when isMainModule and not defined(JS) and not windowsCC89:
when isMainModule and not defined(js) and not windowsCC89:
# Check for no side effect annotation
proc mySqrt(num: float): float {.noSideEffect.} =
return sqrt(num)

View file

@ -83,7 +83,7 @@ import algorithm #For upperBound
include "system/inclrtl"
{.push debugger: off.}
when defined(JS):
when defined(js):
type Ui = uint32
const randMax = 4_294_967_295u32
@ -108,7 +108,7 @@ type
## generator are **not** thread-safe!
a0, a1: Ui
when defined(JS):
when defined(js):
var state = Rand(
a0: 0x69B4C98Cu32,
a1: 0xFED1DD30u32) # global for backwards compatibility
@ -190,7 +190,7 @@ proc skipRandomNumbers*(s: var Rand) =
##
## See also:
## * `next proc<#next,Rand>`_
when defined(JS):
when defined(js):
const helper = [0xbeac0467u32, 0xd86b048bu32]
else:
const helper = [0xbeac0467eba5facbu64, 0xd86b048b86aa9922u64]
@ -216,7 +216,7 @@ proc random*(max: int): int {.benign, deprecated:
proc random*(max: float): float {.benign, deprecated:
"Deprecated since v0.18.0; use 'rand' instead".} =
let x = next(state)
when defined(JS):
when defined(js):
result = (float(x) / float(high(uint32))) * max
else:
let u = (0x3FFu64 shl 52u64) or (x shr 12u64)
@ -287,7 +287,7 @@ proc rand*(r: var Rand; max: range[0.0 .. high(float)]): float {.benign.} =
let f = r.rand(1.0)
## f = 8.717181376738381e-07
let x = next(r)
when defined(JS):
when defined(js):
result = (float(x) / float(high(uint32))) * max
else:
let u = (0x3FFu64 shl 52u64) or (x shr 12u64)
@ -641,7 +641,7 @@ when not defined(nimscript) and not defined(standalone):
## See also:
## * `randomize proc<#randomize,int64>`_ that accepts a seed
## * `initRand proc<#initRand,int64>`_
when defined(JS):
when defined(js):
let time = int64(times.epochTime() * 1000) and 0x7fff_ffff
randomize(time)
else:

View file

@ -196,7 +196,7 @@ import strutils, math, options
include "system/inclrtl"
when defined(JS):
when defined(js):
import jscore
# This is really bad, but overflow checks are broken badly for
@ -1070,7 +1070,7 @@ proc toAdjTime(dt: DateTime): Time =
seconds.inc dt.second
result = initTime(seconds, dt.nanosecond)
when defined(JS):
when defined(js):
proc localZonedTimeFromTime(time: Time): ZonedTime =
let jsDate = newDate(time.seconds * 1000)
let offset = jsDate.getTimezoneOffset() * secondsInMin
@ -1200,7 +1200,7 @@ proc local*(t: Time): DateTime =
proc getTime*(): Time {.tags: [TimeEffect], benign.} =
## Gets the current time as a ``Time`` with up to nanosecond resolution.
when defined(JS):
when defined(js):
let millis = newDate().getTime()
let seconds = convert(Milliseconds, Seconds, millis)
let nanos = convert(Milliseconds, Nanoseconds,
@ -2498,7 +2498,7 @@ proc toTimeInterval*(time: Time): TimeInterval
initTimeInterval(dt.nanosecond, 0, 0, dt.second, dt.minute, dt.hour,
dt.monthday, 0, dt.month.ord - 1, dt.year)
when not defined(JS):
when not defined(js):
type
Clock {.importc: "clock_t".} = distinct int
@ -2559,7 +2559,7 @@ when not defined(JS):
else:
{.error: "unknown OS".}
when defined(JS):
when defined(js):
proc epochTime*(): float {.tags: [TimeEffect].} =
newDate().getTime() / 1000
@ -2664,7 +2664,7 @@ proc fractional*(dur: Duration): Duration {.inline, deprecated.} =
nanoseconds = 9)
initDuration(nanoseconds = dur.nanosecond)
when not defined(JS):
when not defined(js):
proc unixTimeToWinTime*(time: CTime): int64
{.deprecated: "Use toWinTime instead".} =
## Converts a UNIX `Time` (``time_t``) to a Windows file time
@ -2731,7 +2731,7 @@ proc getTimezone*(): int
##
## **Deprecated since v0.18.0:** use ``now().utcOffset`` to get the current
## utc offset (including DST).
when defined(JS):
when defined(js):
return newDate().getTimezoneOffset() * 60
elif defined(freebsd) or defined(netbsd) or defined(openbsd):
# This is wrong since it will include DST offsets, but the behavior has