Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/core/hotcodereloading.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ when defined(hotcodereloading):

proc hasAnyModuleChanged*(): bool = hcrReloadNeeded()

when not defined(JS):
when not defined(js):
template performCodeReload* =
when isMainModule:
{.warning: "Code residing in the main module will not be changed from calling a code-reload".}
Expand Down
4 changes: 2 additions & 2 deletions lib/nimhcr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
# block. Perhaps something can be done about this - some way of re-allocating
# the state and transferring the old...

when not defined(JS) and (defined(hotcodereloading) or
when not defined(js) and (defined(hotcodereloading) or
defined(createNimHcr) or
defined(testNimHcr)):
const
Expand Down Expand Up @@ -612,7 +612,7 @@ when defined(createNimHcr):
global.markerProc()

elif defined(hotcodereloading) or defined(testNimHcr):
when not defined(JS):
when not defined(js):
const
nimhcrLibname = when defined(windows): "nimhcr." & dllExt
elif defined(macosx): "libnimhcr." & dllExt
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/hashes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/pure/math.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down Expand Up @@ -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``.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {.
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions lib/pure/random.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions lib/pure/times.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/std/monotimes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ proc getMonoTime*(): MonoTime {.tags: [TimeEffect].} =
## this proc calls `window.performance.now()`, which is not supported by
## older browsers. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now)
## for more information.
when defined(JS):
when defined(js):
let ticks = getJsTicks()
result = MonoTime(ticks: (ticks * 1_000_000_000).int64)
elif defined(macosx):
Expand Down Expand Up @@ -171,4 +171,4 @@ when isMainModule:
doAssert t1 <= t1
doAssert not(t2 < t1)
doAssert t1 < high(MonoTime)
doAssert low(MonoTime) < t1
doAssert low(MonoTime) < t1
Loading