First suggestion:
src/
<pkgname>.nim
tests/
docs/
<pkgname>.nimble # with srcDir = "src"
library with single module
import macros,options | |
type C = ref object | |
c: int | |
macro until(cond,node,body:untyped):untyped = | |
# Example implementation, just to prove it's possible | |
# Generates: | |
# for raw in b: | |
# if cond(raw): break |
import jsffi | |
type Promise*[T] = ref object of JsObject | |
proc newPromise*[T](executor:proc(resolve:proc(val:T), reject:proc(reason:auto))): Promise[T] {.importcpp: "new Promise(#)".} | |
proc resolve*[T](val:T):Promise[T] {.importcpp: "Promise.resolve(#)",discardable.} | |
proc reject*[T](reason:T):Promise[T] {.importcpp: "Promise.reject(#)",discardable.} | |
proc race*[T](iterable:openarray[T]):Promise[T] {.importcpp: "Promise.race(#)",discardable.} | |
proc all*[T](iterable:openarray[Promise[T]]):Promise[seq[T]] {.importcpp: "Promise.all(#)",discardable.} |
proc itoa(n:int):string = | |
var num = if n<0: -n else: n | |
var i = 0 | |
result = "" | |
while num > 0: | |
result.add(char(48 + num mod 10)) | |
num = num div 10 | |
inc i # inc char count |
import jsffi | |
type Promise*[T] = ref object of JsObject | |
proc newPromise*[T](executor:proc(resolve:proc(val:T), reject:proc(reason:auto))): Promise[T] {.importcpp: "new Promise(#)".} | |
proc resolve*[T](val:T):Promise[T] {.importcpp: "Promise.resolve(#)",discardable.} | |
proc reject*[T](reason:T):Promise[T] {.importcpp: "Promise.reject(#)",discardable.} | |
proc race*[T](iterable:openarray[T]):Promise[T] {.importcpp: "Promise.race(#)",discardable.} | |
proc all*[T](iterable:openarray[Promise[T]]):Promise[seq[T]] {.importcpp: "Promise.all(#)",discardable.} |
First suggestion:
src/
<pkgname>.nim
tests/
docs/
<pkgname>.nimble # with srcDir = "src"
library with single module
a | 0 | |
b | 0 | |
c | 0.0 | |
d | '\0' | |
e | eA | |
f | 0000000000000010"" | |
g | {} | |
h | {} | |
i | [nil, nil, nil] |
<html> | |
<body> | |
<input id="input" type="text" name="fname"> | |
<script src="nimcache/t.js"></script> | |
</body> | |
</html> |
import json | |
#TODO: handle ref,ptr,tuple | |
proc into[T](json:seq[JsonNode],b:var openarray[T]) = | |
## Seq of Omogeneous JsonNodes into an array or seq of type T | |
for i,el in json: | |
when T is bool: | |
b[i] = el.bval | |
elif T is SomeInteger: |
import jester, asyncdispatch | |
from parseopt import getopt,CmdLineKind | |
from strutils import parseint,isDigit | |
from os import dirExists | |
proc usage():string = r""" | |
Usage: jest [<dir>][<port>][--host:<addr>] | |
addr : the address to serve to, default: 'localhost' | |
port : the port to serve to, default: 8000 |