Janet 1.38.0-73334f3 Documentation
(Other Versions: 1.37.1 1.36.0 1.35.0 1.34.0 1.31.0 1.29.1 1.28.0 1.27.0 1.26.0 1.25.1 1.24.0 1.23.0 1.22.0 1.21.0 1.20.0 1.19.0 1.18.1 1.17.1 1.16.1 1.15.0 1.13.1 1.12.2 1.11.1 1.10.1 1.9.1 1.8.1 1.7.0 1.6.0 1.5.1 1.5.0 1.4.0 1.3.1 )

Spork

While not part of Janet's core library, Spork is an official "contributor" library as well as a collection of various useful utilties for Janet.

Spork can be installed with

jpm install spork

Index

spork/argparse/argparse spork/base64/decode spork/base64/encode spork/build-rules/build-rule spork/build-rules/build-run spork/cc/*ar* spork/cc/*build-dir* spork/cc/*build-type* spork/cc/*c++* spork/cc/*c++-std* spork/cc/*c++flags* spork/cc/*c-std* spork/cc/*cc* spork/cc/*cflags* spork/cc/*defines* spork/cc/*dynamic-libs* spork/cc/*lflags* spork/cc/*libs* spork/cc/*msvc-libs* spork/cc/*msvc-vcvars* spork/cc/*pkg-config-flags* spork/cc/*rules* spork/cc/*smart-libs* spork/cc/*static-libs* spork/cc/*target-os* spork/cc/*use-rdynamic* spork/cc/*use-rpath* spork/cc/*visit* spork/cc/check-library-exists spork/cc/compile-and-link-executable spork/cc/compile-and-link-shared spork/cc/compile-and-make-archive spork/cc/compile-c spork/cc/compile-c++ spork/cc/link-executable-c spork/cc/link-executable-c++ spork/cc/link-shared-c spork/cc/link-shared-c++ spork/cc/load-settings spork/cc/make-archive spork/cc/msvc-compile-and-link-executable spork/cc/msvc-compile-and-link-shared spork/cc/msvc-compile-and-make-archive spork/cc/msvc-compile-c spork/cc/msvc-compile-c++ spork/cc/msvc-find spork/cc/msvc-janet-import-lib spork/cc/msvc-link-executable spork/cc/msvc-link-shared spork/cc/msvc-make-archive spork/cc/msvc-setup? spork/cc/pkg-config spork/cc/save-settings spork/cc/search-dynamic-libraries spork/cc/search-libraries spork/cc/search-static-libraries spork/cc/visit-add-rule spork/cc/visit-clean spork/cc/visit-do-nothing spork/cc/visit-execute spork/cc/visit-execute-if-stale spork/cc/visit-execute-quiet spork/cc/visit-generate-makefile spork/channel/from-each spork/cjanet/*cdef-list* spork/cjanet/*cfun-list* spork/cjanet/*indent* spork/cjanet/@ spork/cjanet/block spork/cjanet/cdef spork/cjanet/cfunction spork/cjanet/declare spork/cjanet/emit-block-end spork/cjanet/emit-block-start spork/cjanet/emit-blocks spork/cjanet/emit-cdef spork/cjanet/emit-cfunction spork/cjanet/emit-comment spork/cjanet/emit-declare spork/cjanet/emit-function spork/cjanet/emit-include spork/cjanet/emit-indent spork/cjanet/emit-module-entry spork/cjanet/emit-preprocess spork/cjanet/emit-typedef spork/cjanet/function spork/cjanet/include spork/cjanet/mangle spork/cjanet/module-entry spork/cjanet/preprocess spork/cjanet/type-split spork/cjanet/typedef spork/cmath/invmod spork/cmath/jacobi spork/cmath/mulmod spork/cmath/powmod spork/crc/make-variant spork/crc/named-variant spork/cron/check spork/cron/next-timestamp spork/cron/parse-cron spork/data/diff spork/ev-utils/go-nursery spork/ev-utils/join-nursery spork/ev-utils/multithread-service spork/ev-utils/nursery spork/ev-utils/pcall spork/ev-utils/pdag spork/ev-utils/pmap spork/ev-utils/pmap-full spork/ev-utils/pmap-limited spork/ev-utils/spawn-nursery spork/ev-utils/wait-cancel spork/fmt/*user-indent-2-forms* spork/fmt/format spork/fmt/format-file spork/fmt/format-print spork/generators/concat spork/generators/cycle spork/generators/drop spork/generators/drop-until spork/generators/drop-while spork/generators/filter spork/generators/from-iterable spork/generators/map spork/generators/mapcat spork/generators/range spork/generators/run spork/generators/take spork/generators/take-until spork/generators/take-while spork/generators/to-array spork/getline/default-autocomplete-context spork/getline/default-autocomplete-options spork/getline/default-doc-fetch spork/getline/make-getline spork/getline/max-history spork/htmlgen/doctype-html spork/htmlgen/escape spork/htmlgen/html spork/htmlgen/raw spork/http/cookie-grammar spork/http/cookies spork/http/logger spork/http/middleware spork/http/query-string-grammar spork/http/read-body spork/http/read-request spork/http/read-response spork/http/request spork/http/request-peg spork/http/response-peg spork/http/router spork/http/send-response spork/http/server spork/http/server-handler spork/http/status-messages spork/http/url-grammar spork/httpf/add-bindings-as-routes spork/httpf/add-route spork/httpf/default-payload-wrapper spork/httpf/listen spork/httpf/server spork/infix/$$ spork/json/decode spork/json/encode spork/math/add spork/math/add-to-mean spork/math/approx-eq spork/math/bernoulli-distribution spork/math/binominal-coeficient spork/math/binominal-distribution spork/math/check-probability spork/math/chi-squared-distribution-table spork/math/cols spork/math/copy spork/math/cumulative-std-normal-probability spork/math/det spork/math/dot spork/math/dot-fast spork/math/epsilon spork/math/expand-m spork/math/extent spork/math/factor spork/math/factorial spork/math/fliplr spork/math/flipud spork/math/geometric-mean spork/math/get-only-el spork/math/harmonic-mean spork/math/ident spork/math/interquartile-range spork/math/invmod spork/math/jacobi spork/math/join-cols spork/math/join-rows spork/math/linear-regression spork/math/linear-regression-line spork/math/m-approx= spork/math/matmul spork/math/median spork/math/median-absolute-deviation spork/math/minor spork/math/mode spork/math/mop spork/math/mul spork/math/mulmod spork/math/next-prime spork/math/normalize-v spork/math/outer spork/math/perm spork/math/permutation-test spork/math/permutations spork/math/poisson-distribution spork/math/powmod spork/math/prime? spork/math/primes spork/math/qr spork/math/qr1 spork/math/quantile spork/math/quantile-rank spork/math/quantile-rank-sorted spork/math/quantile-sorted spork/math/quickselect spork/math/relative-err spork/math/root-mean-square spork/math/row->col spork/math/rows spork/math/sample-correlation spork/math/sample-covariance spork/math/sample-skewness spork/math/sample-standard-deviation spork/math/sample-variance spork/math/scalar spork/math/scale spork/math/shuffle-in-place spork/math/sign spork/math/size spork/math/slice-m spork/math/sop spork/math/squeeze spork/math/standard-deviation spork/math/standard-normal-table spork/math/subtract spork/math/sum-compensated spork/math/sum-nth-power-deviations spork/math/svd spork/math/swap spork/math/t-test spork/math/t-test-2 spork/math/trans spork/math/unit-e spork/math/variance spork/math/z-score spork/math/zero spork/mdz/*front-matter* spork/mdz/*markup-dom* spork/mdz/add-loader spork/mdz/anchor spork/mdz/bigger spork/mdz/blockquote spork/mdz/center spork/mdz/code spork/mdz/codeblock spork/mdz/div spork/mdz/em spork/mdz/hr spork/mdz/html spork/mdz/image spork/mdz/li spork/mdz/link spork/mdz/markup spork/mdz/mdz-loader spork/mdz/ol spork/mdz/p spork/mdz/pre spork/mdz/section spork/mdz/smaller spork/mdz/strong spork/mdz/sub spork/mdz/sup spork/mdz/tag spork/mdz/td spork/mdz/th spork/mdz/tr spork/mdz/u spork/mdz/ul spork/misc/always spork/misc/antepenultimate spork/misc/binary-search spork/misc/binary-search-by spork/misc/caperr spork/misc/capout spork/misc/cond-> spork/misc/cond->> spork/misc/dedent spork/misc/defs spork/misc/dfs spork/misc/do-def spork/misc/do-var spork/misc/format-table spork/misc/gett spork/misc/insert-sorted spork/misc/insert-sorted-by spork/misc/int->string spork/misc/int/ spork/misc/log spork/misc/make spork/misc/make-id spork/misc/map-keys spork/misc/map-keys-flat spork/misc/map-vals spork/misc/merge-sorted spork/misc/merge-sorted-by spork/misc/penultimate spork/misc/print-table spork/misc/randomize-array spork/misc/second spork/misc/select-keys spork/misc/set* spork/misc/string->int spork/misc/table-filter spork/misc/third spork/misc/trim-prefix spork/misc/trim-suffix spork/misc/until spork/misc/vars spork/msg/make-proto spork/msg/make-recv spork/msg/make-send spork/netrepl/client spork/netrepl/default-host spork/netrepl/default-port spork/netrepl/server spork/netrepl/server-single spork/path/abspath spork/path/abspath? spork/path/basename spork/path/delim spork/path/dirname spork/path/ext spork/path/join spork/path/normalize spork/path/parts spork/path/posix/abspath spork/path/posix/abspath? spork/path/posix/basename spork/path/posix/delim spork/path/posix/dirname spork/path/posix/ext spork/path/posix/join spork/path/posix/normalize spork/path/posix/parts spork/path/posix/relpath spork/path/posix/sep spork/path/relpath spork/path/sep spork/path/win32/abspath spork/path/win32/abspath? spork/path/win32/basename spork/path/win32/delim spork/path/win32/dirname spork/path/win32/ext spork/path/win32/join spork/path/win32/normalize spork/path/win32/parts spork/path/win32/relpath spork/path/win32/sep spork/pgp/hex->word spork/pgp/hexs->words spork/pgp/word->hex spork/pgp/word-list spork/pgp/words->hexs spork/randgen/*rng* spork/randgen/rand-cdf spork/randgen/rand-cdf-path spork/randgen/rand-gaussian spork/randgen/rand-index spork/randgen/rand-int spork/randgen/rand-path spork/randgen/rand-uniform spork/randgen/rand-value spork/randgen/rand-weights spork/randgen/rand-weights-path spork/randgen/sample-n spork/randgen/set-seed spork/randgen/weights-to-cdf spork/rawterm/begin spork/rawterm/buffer-traverse spork/rawterm/ctrl-z spork/rawterm/end spork/rawterm/getch spork/rawterm/isatty spork/rawterm/monowidth spork/rawterm/rune-monowidth spork/rawterm/size spork/rawterm/slice-monowidth spork/regex/compile spork/regex/find spork/regex/find-all spork/regex/match spork/regex/peg spork/regex/replace spork/regex/replace-all spork/regex/source spork/rpc/client spork/rpc/default-host spork/rpc/default-port spork/rpc/server spork/schema/make-predicate spork/schema/make-validator spork/schema/predicate spork/schema/validator spork/services/*current-manager* spork/services/*current-service* spork/services/add-service spork/services/all-services spork/services/get-manager spork/services/get-service spork/services/make-manager spork/services/print-all spork/services/remove-service spork/services/set-title spork/services/start-service spork/services/stop-service spork/services/wait spork/sh/copy spork/sh/copy-file spork/sh/create-dirs spork/sh/devnull spork/sh/escape spork/sh/exec spork/sh/exec-fail spork/sh/exec-slurp spork/sh/exec-slurp-all spork/sh/exists? spork/sh/list-all-files spork/sh/make-new-file spork/sh/rm spork/sh/scan-directory spork/sh/split spork/stream/lines spork/tarray/buffer spork/tarray/copy-bytes spork/tarray/length spork/tarray/new spork/tarray/properties spork/tarray/slice spork/tarray/swap-bytes spork/tasker/all-tasks spork/tasker/cancel-task spork/tasker/close-queues spork/tasker/default-expiration spork/tasker/default-priority spork/tasker/default-task-directory spork/tasker/err-file-name spork/tasker/max-priority spork/tasker/min-priority spork/tasker/new-tasker spork/tasker/out-file-name spork/tasker/queue-task spork/tasker/run-cleanup spork/tasker/run-executors spork/tasker/spawn-executors spork/tasker/statuses spork/tasker/task-file spork/tasker/task-meta-name spork/tasker/task-status spork/temple/add-loader spork/temple/base-env spork/temple/compile spork/temple/create spork/test/assert spork/test/assert-docs spork/test/assert-error spork/test/assert-no-error spork/test/assert-not spork/test/capture-stderr spork/test/capture-stdout spork/test/end-suite spork/test/start-suite spork/test/suppress-stderr spork/test/suppress-stdout spork/test/timeit spork/test/timeit-loop spork/utf8/decode-rune spork/utf8/encode-rune spork/utf8/prefix->width spork/zip/add-bytes spork/zip/add-file spork/zip/compress spork/zip/decompress spork/zip/extract spork/zip/file-directory? spork/zip/file-encrypted? spork/zip/file-supported? spork/zip/get-filename spork/zip/locate-file spork/zip/read-bytes spork/zip/read-file spork/zip/reader-close spork/zip/reader-count spork/zip/stat spork/zip/version spork/zip/write-buffer spork/zip/write-file spork/zip/writer-close spork/zip/writer-finalize


spork/argparse/argparse function source

(argparse description &keys options)

Parse (dyn :args) according to options. If the arguments are incorrect, will return nil and print usage information.

Each option is a table or struct that specifies a flag or option for the script. The name of the option should be a string, specified via (argparse/argparse "..." op1-name {...} op2-name {...} ...). A help option and usage text is automatically generated for you.

The keys in each option table are as follows:

  • :kind - What kind of option is this? One of :flag, :multi, :option, or :accumulate. A flag can either be on or off, a multi is a flag that can be provided multiple times, each time adding 1 to a returned integer, an option is a key that will be set in the returned table, and accumulate means an option can be specified 0 or more times, each time appending a value to an array.
  • :short - Single letter for shorthand access.
  • :help - Help text for the option, explaining what it is.
  • :default - Default value for the option.
  • :required - Whether or not an option is required.
  • :short-circuit - Whether or not to stop parsing if this option is hit. Result will also contain the rest of the arguments under the :rest key.
  • :action - A function that will be invoked when the option is parsed.
  • :map - A function that is applied to the value of the option to transform it

There is also a special option name :default that will be invoked on arguments that do not start with a -- or -. Use this option to collect unnamed arguments to your script. This is separate from the :default key in option specifiers.

After "--", every argument is treated as an unnamed argument.

Once parsed, values are accessible in the returned table by the name of the option. For example (result "verbose") will check if the verbose flag is enabled. You may also use a custom args array when specified via the special option :args.

EXAMPLES
(import spork)

(def argparse-params
  ["An example CLI tool."
   "my-flag" {:kind :flag
              :short "f"
              :help "set my-flag"}
   "my-opt" {:kind :option
             :short "o"
             :help "Value for option"
             :default "DEFAULT VALUE"}
   "my-req" {:kind :option
             :short "r"
             :required true}])

(def cli-args (spork/argparse/argparse ;argparse-params))

(unless cli-args
  (os/exit 1))

(print "flag: " (get cli-args "my-flag"))
(print "my-opt: " (get cli-args "my-opt"))
(print "my-req: " (get cli-args "my-req"))

spork/base64/decode cfunction

(base64/decode x)

Decodes a string from Base64. Returns decoded string.


spork/base64/encode cfunction

(base64/encode x)

Encodes a string in Base64. Returns encoded string.


spork/build-rules/build-rule macro source

(build-rule rules target deps & body)

Add a rule to the rule graph. rules should be a table, target a string or tuple of strings, and deps a tuple of strings. body is code that will be executed to create all of the targets by the rules. If target is a keyword, the rule will always be considered out of date.


spork/build-rules/build-run function source

(build-run rules targets &opt n-workers)

Build a list of targets, as specified by rules. Return an array of all recursively updated targets.


spork/cc/*ar* keyword source

Archiver, defaults to ar.


spork/cc/*build-dir* keyword source

If generating intermediate files, store them in this directory


spork/cc/*build-type* keyword source

Presets for compiler optimizations, can be :release, :develop, and :debug, defaults to :develop.


spork/cc/*c++* keyword source

C++ compiler, defaults to c++.


spork/cc/*c++-std* keyword source

C++ standard to use as a 2 digit number, defaults to 11 on GCC-like compilers, 14 on msvc.


spork/cc/*c++flags* keyword source

Extra C++ compiler flags to use during compilation


spork/cc/*c-std* keyword source

C standard to use as a 2 digit number, defaults to 99 on GCC-like compilers, 11 on msvc.


spork/cc/*cc* keyword source

C compiler, defaults to cc.


spork/cc/*cflags* keyword source

Extra C compiler flags to use during compilation


spork/cc/*defines* keyword source

Map of extra defines to use when compiling


spork/cc/*dynamic-libs* keyword source

List of dynamic libraries to use when compiling


spork/cc/*lflags* keyword source

Extra linker flags


spork/cc/*libs* keyword source

List of libraries to use when compiling - can be static or dynamic depending on system.


spork/cc/*msvc-libs* keyword source

List of .lib libraries to use when compiling with msvc


spork/cc/*msvc-vcvars* keyword source

Path to vcvarsall.bat to use initialize MSVC environment. If unset, msvc-find will try to guess using typical install locations.


spork/cc/*pkg-config-flags* keyword source

Extra flags to pass to pkg-config


spork/cc/*rules* keyword source

Rules to use with visit-add-rule


spork/cc/*smart-libs* keyword source

Try to resolve circular or out-of-order dependencies between libraries by using --start-group and --end-group. Some linkers support this by default, but not at all. Defaults to true on linux and macos.


spork/cc/*static-libs* keyword source

List of static libraries to use when compiling


spork/cc/*target-os* keyword source

Operating system to assume is being used for target compiler toolchain


spork/cc/*use-rdynamic* keyword source

Optional setting to enable using -rdynamic or -Wl,-export_dynamic when linking executables. This is the preferred way on POSIX systems to let an executable load native modules dynamically at runtime. Defaults to true


spork/cc/*use-rpath* keyword source

Optional setting to enable using (dyn *syspath*) as the runtime path to load for Shared Objects. Defaults to true


spork/cc/*visit* keyword source

Optional callback to process each CLI command and its inputs and outputs


spork/cc/check-library-exists function source

(check-library-exists libname &opt binding test-source-code)

Check if a library exists on the current POSIX system. Will run a test compilation and return true if the compilation succeeds. Libname is passed directly to the compiler/linker, such as -lm on GNU/Linux.


spork/cc/compile-and-link-executable function source

(compile-and-link-executable to & sources)

Compile and link an executable C/C++ program. Return an array of commands.


spork/cc/compile-and-link-shared function source

(compile-and-link-shared to & sources)

Compile and link a shared C/C++ library. Return an array of commands.


spork/cc/compile-and-make-archive function source

(compile-and-make-archive to & sources)

Compile and create a static archive. Return an array of commands.


spork/cc/compile-c function source

(compile-c from to)

Compile a C program to an object file. Return the command arguments.


spork/cc/compile-c++ function source

(compile-c++ from to)

Compile a C++ program to an object file. Return the command arguments.


spork/cc/link-executable-c function source

(link-executable-c objects to)

Link a C program to make an executable. Return the command arguments.


spork/cc/link-executable-c++ function source

(link-executable-c++ objects to)

Link a C++ program to make an executable. Return the command arguments.


spork/cc/link-shared-c function source

(link-shared-c objects to)

Link a C program to make a shared library. Return the command arguments.


spork/cc/link-shared-c++ function source

(link-shared-c++ objects to)

Link a C++ program to make a shared library. Return the command arguments.


spork/cc/load-settings function source

(load-settings settings)

Load settings from a snapshot of settings saved with save-settings.


spork/cc/make-archive function source

(make-archive objects to)

Make an archive file. Return the command arguments.


spork/cc/msvc-compile-and-link-executable function source

(msvc-compile-and-link-executable to & sources)

Compile and link an executable C/C++ program. Return an array of commands.


spork/cc/msvc-compile-and-link-shared function source

(msvc-compile-and-link-shared to & sources)

Compile and link a shared C/C++ library. Return an array of commands.


spork/cc/msvc-compile-and-make-archive function source

(msvc-compile-and-make-archive to & sources)

Compile and create a static archive. Return an array of commands.


spork/cc/msvc-compile-c function source

(msvc-compile-c from to)

Compile a C program with MSVC. Return the command arguments.


spork/cc/msvc-compile-c++ function source

(msvc-compile-c++ from to)

Compile a C++ program with MSVC. Return the command arguments.


spork/cc/msvc-find function source

(msvc-find)

Find vcvarsall.bat and run it to setup the current environment for building. Uses (dyn *msvc-vcvars*) to find the location of the setup script, otherwise defaults to checking typical install locations for Visual Studio. Supports VS 2017, 2019, and 2022, any edition. Will set environment variables such that invocations of cl.exe, link.exe, etc. will work as expected.


spork/cc/msvc-janet-import-lib function source

(msvc-janet-import-lib)

Get path to the installed Janet import lib. This import lib is needed when create dlls for natives.


spork/cc/msvc-link-executable function source

(msvc-link-executable objects to)

Link a C/C++ program with MSVC to make an executable. Return the command arguments.


spork/cc/msvc-link-shared function source

(msvc-link-shared objects to)

Link a C/C++ program with MSVC to make a shared library. Return the command arguments.


spork/cc/msvc-make-archive function source

(msvc-make-archive objects to)

Make an archive file with MSVC. Return the command arguments.


spork/cc/msvc-setup? function source

(msvc-setup?)

Check if MSVC environment is already setup.


spork/cc/pkg-config function source

(pkg-config & pkg-config-libraries)

Setup defines, cflags, and library flags from pkg-config.


spork/cc/save-settings function source

(save-settings)

Get a snapshot of the current settings for various compiler flags, libraries, defines, etc. that can be loaded later.


spork/cc/search-dynamic-libraries function source

(search-dynamic-libraries & libs)

Search for dynamic libraries on the current POSIX system and configure (dyn *dynamic-libraries*). This is done by checking for the existence of libraries with check-library-exists. Returns an array of libraries that were not found.


spork/cc/search-libraries function source

(search-libraries & libs)

Search for libraries on the current POSIX system and configure (dyn *libs*). This is done by checking for the existence of libraries with check-library-exists. Returns an array of libraries that were not found.


spork/cc/search-static-libraries function source

(search-static-libraries & libs)

Search for static libraries on the current POSIX system and configure (dyn *static-libs*). This is done by checking for the existence of libraries with check-library-exists. Returns an array of libraries that were not found.


spork/cc/visit-add-rule function source

(visit-add-rule cmd inputs outputs message)

Used in conjuction with spork/build-rules. Adds rules to the (dyn *rules* (curenv))


spork/cc/visit-clean function source

(visit-clean cmd inputs outputs message)

A visiting function that will remove all outputs.


spork/cc/visit-do-nothing function source

(visit-do-nothing &)

A visiting function that has no side effects and therefor does nothing.


spork/cc/visit-execute function source

(visit-execute cmd inputs outputs message)

A function that can be provided as (dyn *visit*) that will execute commands.


spork/cc/visit-execute-if-stale function source

(visit-execute-if-stale cmd inputs outputs message)

A function that can be provided as (dyn *visit*) that will execute a command if inputs are newer than outputs, providing a simple, single-threaded, incremental build tool. This is not optimal for parallel builds, but is simple and works well for small projects.


spork/cc/visit-execute-quiet function source

(visit-execute-quiet cmd inputs outputs message)

A function that can be provided as (dyn *visit*) that will execute commands quietly.


spork/cc/visit-generate-makefile function source

(visit-generate-makefile cmd inputs outputs message)

A function that can be provided as (dyn *visit*) that will generate Makefile targets.


spork/channel/from-each function source

(from-each iterable &named supervisor)

Returns a channel that gives each item from an iterable data type. each macro is used to iterate over all iterable types. supervisor argument is passed to ev/go which launches two tasks that feed items to the channel. To finish the tasks, drain all items from the channel, or close the channel. Otherwise, the tasks remain frozen. When the tasks finish, the channel is closed. An error caused during iteration finishes the tasks with an error. Writing to the channel finishes the tasks with an error or freezes the fiber that tries to write to the channel.


spork/cjanet/*cdef-list* keyword source

Array of C Constants defined in the current scope


spork/cjanet/*cfun-list* keyword source

Array of C Functions defined in the current scope


spork/cjanet/*indent* keyword source

current indent buffer


spork/cjanet/@ macro source

(@ & args)


spork/cjanet/block macro source

(block & args)


spork/cjanet/cdef macro source

(cdef name & more)

Define constant which will be registered in the module. It takes care of the docstring.


spork/cjanet/cfunction macro source

(cfunction name & more)

Define a C Function in cjanet. This also takes care of recording docstrings and such. Arity checking will be generated for you (by insertion of a call to janet_arity or janet_fixarity).


spork/cjanet/declare macro source

(declare & args)


spork/cjanet/emit-block-end function source

(emit-block-end &opt nl)


spork/cjanet/emit-block-start function source

(emit-block-start)


spork/cjanet/emit-blocks function source

(emit-blocks statements)

Emit a number of statements in a bracketed block


spork/cjanet/emit-cdef function source

(emit-cdef name & more)

Define constant which will be registered in the module. It takes care of the docstring.


spork/cjanet/emit-cfunction function source

(emit-cfunction name & more)

Functional form of cfunction - takes the same arguments, but parameters must be manually quoted.


spork/cjanet/emit-comment function source

(emit-comment msg)

Emit a multi-line comment string for C


spork/cjanet/emit-declare function source

(emit-declare binding & form)

Emit a declaration of a variable or constant.


spork/cjanet/emit-function function source

(emit-function name & form)

Emit a C function definition.


spork/cjanet/emit-include function source

(emit-include path)


spork/cjanet/emit-indent function source

(emit-indent)


spork/cjanet/emit-module-entry function source

(emit-module-entry name)

Call this at the end of a cjanet module to add a module entry function.


spork/cjanet/emit-preprocess function source

(emit-preprocess & args)

Emit a line of source code for the pre-processor. For example (emit-preprocess "include" "<stdio.h>").


spork/cjanet/emit-typedef function source

(emit-typedef name definition)

Emit a type declaration (C typedef).


spork/cjanet/function macro source

(function & args)


spork/cjanet/include macro source

(include path)


spork/cjanet/mangle function source

(mangle token)

Convert any sequence of bytes to a valid C identifier in a way that is unlikely to collide. print-ir will not mangle symbols for you.


spork/cjanet/module-entry macro source

(module-entry name)

Call this at the end of a cjanet module to add a module entry function.


spork/cjanet/preprocess macro source

(preprocess & args)


spork/cjanet/type-split function source

(type-split x &opt dflt-type)

Extract name and type from a variable. Allow typing variables as both (name type) or name:type as a shorthand. If no type is found, default to dflt-type. dflt-type itself defaults to 'auto


spork/cjanet/typedef macro source

(typedef & args)


spork/cmath/invmod cfunction source

(math/invmod a m)

Modular multiplicative inverse of a mod m. Both arguments must be integer. The return value has the same type as m. If no inverse exists, returns math/nan instead.


spork/cmath/jacobi cfunction source

(math/jacobi a m)

Computes the Jacobi Symbol (a|m).


spork/cmath/mulmod cfunction source

(math/mulmod a b m)

Modular multiplication of a and b mod m. All arguments must be integer. The return value has the same type as m.


spork/cmath/powmod cfunction source

(math/powmod a b m)

Modular exponentiation of a to the power of b mod m. All arguments must be integer. The return value has the same type as m.


spork/crc/make-variant cfunction source

(crc/make-variant size polynomial &opt init byte-flip xorout)

Create a CRC function based on the given polynomial, initial value, xourout, and whether to invert input bytes.


spork/crc/named-variant cfunction source

(crc/named-variant name)

Get a named CRC variant.


spork/cron/check function source

(check cron &opt time local)

Check if a given time matches a cron specifier.


spork/cron/next-timestamp function source

(next-timestamp cron &opt time local)

Given a cron schedule, get the next instance on the cron tab after time


spork/cron/parse-cron function source

(parse-cron str)

Parse a cron string into a valid cron schedule object


spork/data/diff var (function)

(diff a b)

Compares a and b recursively. Returns an array of @[things-only-in-a things-only-in-b things-in-both].


spork/ev-utils/go-nursery function source

(go-nursery nurse f &opt value)

Spawn a fiber into a nursery, similar to ev/go.


spork/ev-utils/join-nursery function source

(join-nursery nurse)

Suspend the current fiber until the nursery is emptied.


spork/ev-utils/multithread-service function source

(multithread-service thread-main n-threads)

Run instances of a function over multiple threads. On failures, restart the failed thread. Normal function returns will not trigger a restart.


spork/ev-utils/nursery function source

(nursery)

Group a number of fibers into a single object for structured concurrency


spork/ev-utils/pcall function source

(pcall f n)

Call a function n times (in parallel) for side effects. Each function is called with an integer argument indicating a fiber index. Returns nil.


spork/ev-utils/pdag function source

(pdag f dag &opt n-workers)

Executes a dag by calling f on every node in the graph. Can set the number of workers for parallel execution. The graph is represented as a table mapping nodes to arrays of child nodes. Each node will only be evaluated after all children have been evaluated. Modifying dag inside f will not affect the scheduling of workers. Returns a table mapping each node to the result of (f node).


spork/ev-utils/pmap function source

(pmap f data &opt n-workers)

Map f over data in parallel, optionally limiting parallelism to n workers.


spork/ev-utils/pmap-full function source

(pmap-full f data)

Function form of ev/gather. If any of the sibling fibers error, all other siblings will be canceled. Returns the gathered results in an array. data can be any indexed data structure.


spork/ev-utils/pmap-limited function source

(pmap-limited f data n-workers)

Similar to pmap-full, but only runs work n-ways parallel.


spork/ev-utils/spawn-nursery macro source

(spawn-nursery nurse & body)

Similar to ev/spawn but associate spawned fibers with a nursery


spork/ev-utils/wait-cancel macro source

(wait-cancel & body)

Wait forever until the current fiber is canceled, and then run some cleanup code.


spork/fmt/*user-indent-2-forms* keyword source

A user list of forms that are control forms and should be indented two spaces.


spork/fmt/format function source

(format source)

Format a string of source code to a buffer.


spork/fmt/format-file function source

(format-file file)

Format a file


spork/fmt/format-print function source

(format-print source)

Format a string of source code and print the result.


spork/generators/concat function source

(concat & xs)

Concatenate one or more generators or iterables into a single generator.


spork/generators/cycle function source

(cycle ds)

Repeatedly yield the elements of ds, looping back to the beginning when finished.


spork/generators/drop function source

(drop n ds)

Drop n elements from ds.


spork/generators/drop-until function source

(drop-until p ds)

Drop elements from ds until p is true.


spork/generators/drop-while function source

(drop-while p ds)

Drop elements from ds while p is true.


spork/generators/filter function source

(filter p ds)

Create a generator that filters ds with p.


spork/generators/from-iterable function source

(from-iterable ds)

Create a new generator around any iterable data structure.


spork/generators/map function source

(map f ds)

Create a generator that maps f over ds.


spork/generators/mapcat function source

(mapcat f ds)

Map f over ds, concatenating the results into a new generator.


spork/generators/range function source

(range from to)

Create a lazy range.


spork/generators/run function source

(run s)

Evaluate s for side effects.


spork/generators/take function source

(take n ds)

Take n elements from iterable ds.


spork/generators/take-until function source

(take-until p ds)

Return elements from ds until p is true.


spork/generators/take-while function source

(take-while p ds)

Return elements from ds while p is true.


spork/generators/to-array function source

(to-array s)

Consume s into a new array.


spork/getline/default-autocomplete-context function source

(default-autocomplete-context buf pos)

Given a buffer and a cursor position, extract a string that will be used as context for autocompletion. Return a position and substring from the buffer to use for autocompletion.


spork/getline/default-autocomplete-options function source

(default-autocomplete-options prefix &)

Default handler to get available autocomplete options for a given substring.


spork/getline/default-doc-fetch function source

(default-doc-fetch sym w &)

Default handler for Ctrl-G to lookup docstrings in the current environment.


spork/getline/make-getline function source

(make-getline &opt autocomplete-context autocomplete-options doc-fetch)

Reads a line of input into a buffer, like getline. However, allow looking up entries with a general lookup function rather than an environment table.


spork/getline/max-history number source

Maximal amount of items in the history


spork/htmlgen/doctype-html function source

The html5 doctype header


spork/htmlgen/escape function source

(escape x)

Escape characters in a string for HTML


spork/htmlgen/html function source

(html data &opt buf)

Render HTML from standard data structures. Fills the provided optional buffer, or new one if it is not provided, with the html bytes.


spork/htmlgen/raw function source

(raw text)

Get an object that can be used to splice in HTML literals. text is not escaped in the output string.


spork/http/cookie-grammar core/peg source

Grammar to parse a cookie header to a series of keys and values.


spork/http/cookies function source

(cookies nextmw)

Parses cookies into the table under :cookies key


spork/http/logger function source

(logger nextmw)

Creates a logging middleware. The logger middleware prints URL route, return status, and elapsed request time.


spork/http/middleware function source

(middleware x)

Coerce any type to http middleware


spork/http/query-string-grammar core/peg source

Grammar that parses a query string (sans url path and ? character) and returns a table.


spork/http/read-body function source

(read-body req)

Given a request, read the HTTP body from the connection. Returns the body as a buffer. If the request has no body, returns nil.


spork/http/read-request function source

(read-request conn buf &opt no-query)

Read an HTTP request header from a connection. Returns a table with the following keys:

  • :headers - table mapping header names to header values. Header names are lowercase.
  • :connection - the connection stream for the header.
  • :buffer - the buffer instance that may contain extra bytes.
  • :head-size - the number of bytes used by the header.
  • :method - the HTTP method used.
  • :path - the path of the resource requested.

The following keys are also present, but omitted if the user passes a truthy parameter to no-query.

  • :route - path of the resource requested without query string.
  • :query-string - segment of HTTP path after first ? character.
  • :query - the query string parsed into a table. Supports a single string value for every string key, and any query parameters that aren't given a value are mapped to true.

Note that data is read in chunks and any data after the header terminator is stored in :buffer.


spork/http/read-response function source

(read-response conn buf)

Read an HTTP response header from a connection. Returns a table with the following keys:

  • :headers - table mapping header names to header values. Header names are lowercase.
  • :connection - the connection stream for the header.
  • :buffer - the buffer instance that may contain extra bytes.
  • :head-size - the number of bytes used by the header.
  • :status - the HTTP status code.
  • :message - the HTTP status message.

Note that data is read in chunks and any data after the header terminator is stored in :buffer.


spork/http/request function source

(request method url &keys {:body body :headers headers})

Make an HTTP request to a server. Returns a table containing response information.

  • :head-size - number of bytes in the http header
  • :headers - table mapping header names to header values. Header names are lowercase.
  • :connection - the connection stream for the header.
  • :buffer - the buffer instance that may contain extra bytes.
  • :status - HTTP status code as an integer.
  • :message - HTTP status message.
  • :body - Bytes of the response body.

spork/http/request-peg core/peg source

PEG for parsing HTTP requests


spork/http/response-peg core/peg source

PEG for parsing HTTP responses


spork/http/router function source

(router routes)

Creates a router middleware. A router will dispatch to different routes based on the URL path.


spork/http/send-response function source

(send-response conn response &opt buf)

Send an HTTP response over a connection. Will automatically use chunked encoding if body is not a byte sequence. response should be a table with the following keys:

  • :headers - optional headers to write
  • :status - integer status code to write
  • :body - optional byte sequence or iterable (for chunked body) for returning contents. The iterable can be lazy, i.e. for streaming data.

spork/http/server function source

(server handler &opt host port)

Makes a simple http server. By default it binds to 0.0.0.0:8000, returns a new server stream. Simply wraps http/server-handler with a net/server.


spork/http/server-handler function source

(server-handler conn handler)

A simple connection handler for an HTTP server. When a connection is accepted. Call this with a handler function to handle the connect. The handler will be called with one argument, the request table, which will contain the following keys:

  • :head-size - number of bytes in the http header.
  • :headers - table mapping header names to header values.
  • :connection - the connection stream for the header.
  • :buffer - the buffer instance that may contain extra bytes.
  • :path - HTTP path.
  • :method - HTTP method, as a string.

spork/http/status-messages struct source

Mapping of HTTP status codes to their status message.


spork/http/url-grammar core/peg source

Grammar to parse a URL into domain, port, and path triplet. Only supports the http:// protocol.


spork/httpf/add-bindings-as-routes function source

(add-bindings-as-routes server &opt env)

Add all local functions defined with :path metadata to a server. Will read from the :schema, :doc, :path, and :route-doc metadata to determine how the route behaves.


spork/httpf/add-route function source

(add-route server path docstring schema handler &opt read-mime render-mime)

Add a single route manually to a server. Prefer using httpf/add-bindings-as-routes for the usual case.


spork/httpf/default-payload-wrapper function source

(default-payload-wrapper payload)

Add some metadata to all responses


spork/httpf/listen function source

(listen server &opt host port n-workers)

Start server


spork/httpf/server function source

(server &opt parent)

Create a new server.


spork/infix/$$ macro source

($$ & body)

Use infix syntax for writing expressions in a more familiar manner. Useful for writing mathematic expressions.


spork/json/decode cfunction

(json/decode json-source &opt keywords nils)

Returns a janet object after parsing JSON. If keywords is truthy, string keys will be converted to keywords. If nils is truthy, null will become nil instead of the keyword :null.


spork/json/encode cfunction

(json/encode x &opt tab newline buf)

Encodes a janet value in JSON (utf-8). tab and newline are optional byte sequence which are used to format the output JSON. if buf is provided, the formated JSON is append to buf instead of a new buffer. Returns the modifed buffer.


spork/math/add function source

(add m a)

Add a to matrix m where it can be matrix or scalar. Matrix m is mutated.


spork/math/add-to-mean function source

(add-to-mean m n v)

Adds new value v to mean m from n values.


spork/math/approx-eq function source

(approx-eq a e &opt t)

Approximate equality between actual number a and expected number e. Default tolerance t is epsilon.


spork/math/bernoulli-distribution function source

(bernoulli-distribution p)

Creates Bernoulli distribution from probability p in the tuple.


spork/math/binominal-coeficient function source

(binominal-coeficient n k)

Computes binominal coefficient from set of size n and sample size k.


spork/math/binominal-distribution function source

(binominal-distribution t p)

Creates binominal distribution from trials t and probability p in the tuple.


spork/math/check-probability function source

(check-probability p)

Asserts that probability is in the [0 1] range.


spork/math/chi-squared-distribution-table struct source

Chi Squared distribution table.


spork/math/cols function source

(cols m)

Returns number of columns of matrix m.


spork/math/copy function source

(copy xs)

Deep copy an array or view xs.


spork/math/cumulative-std-normal-probability function source

(cumulative-std-normal-probability z)

Computes standard normal probability for y.


spork/math/det function source

(det m)

Computes determinant of matrix m.


spork/math/dot function source

(dot v1 v2)

Dot product between two row vectors.


spork/math/dot-fast function source

(dot-fast v1 v2)

Fast dot product between two row vectors of equal size.


spork/math/epsilon number source

Epsilon constant


spork/math/expand-m function source

(expand-m n m)

Embeds a matrix m inside an identity matrix of size n.


spork/math/extent function source

(extent xs)

Returns the minimum & maximum number in an xs as tuple.


spork/math/factor function source

(factor n)

Returns an array containing the prime factors of n.


spork/math/factorial function source

(factorial n)

Returns factorial of n.


spork/math/fliplr function source

(fliplr m)

Flip a matrix leftside-right.


spork/math/flipud function source

(flipud m)

Flip a matrix upside-down.


spork/math/geometric-mean function source

(geometric-mean xs)

Gets the geometric mean from xs.


spork/math/get-only-el macro source

(get-only-el m)

Convenience macro for geting first element from first row of the two dimensional array m.


spork/math/harmonic-mean function source

(harmonic-mean xs)

Gets the harmonic mean from xs.


spork/math/ident function source

(ident c)

Creates identity matrix with c x c size.


spork/math/interquartile-range function source

(interquartile-range xs)

Gets the interquartile range from xs.


spork/math/invmod cfunction source

(math/invmod a m)

Modular multiplicative inverse of a mod m. Both arguments must be integer. The return value has the same type as m. If no inverse exists, returns math/nan instead.


spork/math/jacobi cfunction source

(math/jacobi a m)

Computes the Jacobi Symbol (a|m).


spork/math/join-cols function source

(join-cols m1 m2)

Stack horizontally columns of two matrices.


spork/math/join-rows function source

(join-rows m1 m2)

Stack vertically rows of two matrices.


spork/math/linear-regression function source

(linear-regression coords)

Computes the slope :m and y-intercept :b of the function in the struct from set of coordinates.


spork/math/linear-regression-line function source

(linear-regression-line {:b b :m m})

Constructs function from struct returned by linear regression.


spork/math/m-approx= function source

(m-approx= m1 m2 &opt tolerance)

Compares two matrices of equal size for equivalence within epsilon.


spork/math/matmul function source

(matmul ma mb)

Matrix multiplication between matrices ma and mb. Does not mutate.


spork/math/median function source

(median xs)

Gets the median value from xs


spork/math/median-absolute-deviation function source

(median-absolute-deviation xs)

Gets median absolute deviation from xs.


spork/math/minor function source

(minor m x y)

Computes minor matrix of matrix m and x, y.


spork/math/mode function source

(mode xs)

Gets the mode value from xs.


spork/math/mop function source

(mop m op a)

Mutates every cell of the matrix m with op and corresponding cell from matrix arg a.


spork/math/mul function source

(mul m a)

Multiply matrix m with a which can be matrix or a list. Mutates m. A list a will be converted to column vector then multiplifed from the right as x * a.


spork/math/mulmod cfunction source

(math/mulmod a b m)

Modular multiplication of a and b mod m. All arguments must be integer. The return value has the same type as m.


spork/math/next-prime function source

(next-prime n)

Returns the next prime number strictly larger than n.


spork/math/normalize-v function source

(normalize-v xs)

Returns normalized vector of xs by Euclidian (L2) norm.


spork/math/outer function source

(outer v1 v2)

Outer product of vectors v1 and v2.


spork/math/perm function source

(perm m)

Computes permanent of the matrix m.


spork/math/permutation-test function source

(permutation-test xs ys &opt a k)

Conducts a permutation test to determine if two data sets xs and ys are *significantly* different from each other. You can use alternative hypothesis a, which defaults to :two-side, with :greater and :lesser being the other two options. The last optional argument is k number of values in permutation distribution


spork/math/permutations function source

(permutations s &opt k)

Returns permutations of length k from members of s


spork/math/poisson-distribution function source

(poisson-distribution lambda)

Creates Poisson distribution from lambda in tuple.


spork/math/powmod cfunction source

(math/powmod a b m)

Modular exponentiation of a to the power of b mod m. All arguments must be integer. The return value has the same type as m.


spork/math/prime? function source

(prime? n)

A primality test, deterministic for all n less than 2^63.


spork/math/primes function source

(primes)

A boundless prime number generator.


spork/math/qr function source

(qr m)

Stable and robust QR decomposition of a matrix. Decompose a matrix using Householder transformations. O(n^3).


spork/math/qr1 function source

(qr1 m)

Transform using Householder reflections by one step.


spork/math/quantile function source

(quantile xs p)

Gets the quantile value from xs at p from unsorted population.


spork/math/quantile-rank function source

(quantile-rank xs p)

Gets the quantile rank of value v from unsorted xs.


spork/math/quantile-rank-sorted function source

(quantile-rank-sorted xs v)

Gets the quantile rank of value v from sorted xs.


spork/math/quantile-sorted function source

(quantile-sorted xs p)

Gets the quantile value from xs at p from sorted population.


spork/math/quickselect function source

(quickselect arr k &opt left right)

Rearrange items in arr so that all items in [left, k] range are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right]. Mutates arr.


spork/math/relative-err function source

(relative-err a e)

Gets the relative err between actual number a and expected number e.


spork/math/root-mean-square function source

(root-mean-square xs)

Gets the root mean square from xs.


spork/math/row->col function source

(row->col xs)

Transposes a row vector xs to col vector. Returns xs if it has higher dimensions.


spork/math/rows function source

(rows m)

Returns number of rows of matrix m.


spork/math/sample-correlation function source

(sample-correlation xs ys)

Gets the sample correlation between xs and ys.


spork/math/sample-covariance function source

(sample-covariance xs ys)

Gets the sample covariance between xs and ys.


spork/math/sample-skewness function source

(sample-skewness xs)

Gets the sample skeweness from the xs.


spork/math/sample-standard-deviation function source

(sample-standard-deviation xs)

Gets sample standard deviation from xs.


spork/math/sample-variance function source

(sample-variance xs)

Get the sample variance from xs.


spork/math/scalar function source

(scalar c s)

Creates scalar s matrix with c x c size.


spork/math/scale function source

(scale v k)

Scale a vector v by a number k.


spork/math/shuffle-in-place function source

(shuffle-in-place xs)

Generate random permutation of the array xs which is shuffled in place.


spork/math/sign function source

(sign x)

Sign function.


spork/math/size function source

(size m)

Returns tuple with the matrix m size [rows cols].


spork/math/slice-m function source

(slice-m m rslice cslice)

Slice a matrix m by rows and columns.


spork/math/sop function source

(sop m op & a)

Mutates every cell of the matrix m with op and variadic args a.


spork/math/squeeze function source

(squeeze m)

Concatenate a list of rows into a single row. Does not mutate m.


spork/math/standard-deviation function source

(standard-deviation xs)

Gets the standard deviation from ds.


spork/math/standard-normal-table tuple source

Computed standard normal table.


spork/math/subtract function source

(subtract v1 v2)

Elementwise subtract vector v2 from v1.


spork/math/sum-compensated function source

(sum-compensated xs)

Returns sum of the members of xs with Kahan-Babushka algorithm.


spork/math/sum-nth-power-deviations function source

(sum-nth-power-deviations xs n)

Get the sum of deviations to the n power.


spork/math/svd function source

(svd m &opt n-iter)

Simple Singular-Value-Decomposition based on repeated QR decomposition. The algorithm converges at O(n^3).


spork/math/swap function source

(swap arr i j)

Swaps members with indices i and j of arr. Noop when i equals j.


spork/math/t-test function source

(t-test xs expv)

Computes one sample t-test comparing the mean of xs to known value expv.


spork/math/t-test-2 function source

(t-test-2 xs ys &opt d)

Computes two sample t-test of two samples xs and ys with difference optional d which defaults to 0.


spork/math/trans function source

(trans m)

Tansposes a list of row vectors.


spork/math/unit-e function source

(unit-e n k)

Unit vector of n dimensions along dimension k.


spork/math/variance function source

(variance xs)

Get the variance from the xs.


spork/math/z-score function source

(z-score x m d)

Gets the standard score for number x from mean m and standard deviation d.


spork/math/zero function source

(zero c &opt r)

Creates vector of length c, or matrix if r is provided, and fills it with zeros.


spork/mdz/*front-matter* keyword source

Dynamic binding to front matter of markup after parsing, compilation, and evaluation completes.


spork/mdz/*markup-dom* keyword source

The htmlgen source that can be used to generate a document with htmlgen/html.


spork/mdz/add-loader function source

(add-loader)

Allow importing and requiring markup as a module


spork/mdz/anchor function source

(anchor name & content)

Create an in-page anchor for a local link.


spork/mdz/bigger function source

(bigger content)

Make span element with bigger font


spork/mdz/blockquote function source

(blockquote content)

Make a block quote element


spork/mdz/center function source

(center content)

Center some content


spork/mdz/code function source

(code content)

Make code element with class mendoza-code


spork/mdz/codeblock function source

(codeblock lang &opt source)

Inline code or codeblock


spork/mdz/div function

Make a div element


spork/mdz/em function

Make a em element


spork/mdz/hr function source

(hr)

Add a horizontal rule


spork/mdz/html function source

(html source)

Embed some raw html


spork/mdz/image function source

(image src alt)

Make an image element


spork/mdz/li function

Make a li element


spork/mdz/link function source

(link url &opt content)

Create an anchor link


spork/mdz/markup function source

(markup source &opt env where)

Parse mendoza markup and evaluate it returning an htmlgen document tree.


spork/mdz/mdz-loader function source

(mdz-loader path &)

Loader for the mdz format


spork/mdz/ol function

Make a ol element


spork/mdz/p function

Make a p element


spork/mdz/pre function

Make a pre element


spork/mdz/section function source

(section name content)

Create a section. Usually used to embed different parts of the content document into different parts of the main page.


spork/mdz/smaller function source

(smaller content)

Make span element with smaller font


spork/mdz/strong function

Make a strong element


spork/mdz/sub function

Make a sub element


spork/mdz/sup function

Make a sup element


spork/mdz/tag function source

(tag name content)

Wrap some content in an html tag. If you need attributes or other properties, you may want to use raw HTML via the html function.


spork/mdz/td function

Make a td element


spork/mdz/th function

Make a th element


spork/mdz/tr function

Make a tr element


spork/mdz/u function

Make a u element


spork/mdz/ul function

Make a ul element


spork/misc/always function source

(always x)

Return a function that discards any arguments and always returns x.


spork/misc/antepenultimate function source

(antepenultimate xs)

Get the third-to-last element from an indexed data structure.


spork/misc/binary-search macro source

(binary-search x arr &opt <?)

Returns the index of x in a sorted array or tuple or the index of the next item if x is not present. This is the correct insert index for x within arr. If a <? comparator is given, the search uses that to compare elements, otherwise uses <.


spork/misc/binary-search-by macro source

(binary-search-by x arr f)

Returns the index of x in an array or tuple which has been sorted by a mapping function f, or the index of the next item if x is not present. This is the correct insert index for x within arr.


spork/misc/caperr macro source

(caperr & body)

Captures the standard error output of the variadic body and returns it as a buffer.


spork/misc/capout macro source

(capout & body)

Captures the standard output of the variadic body and returns it as a buffer.


spork/misc/cond-> macro source

(cond-> val & clauses)

Threading conditional macro. It takes val to mutate, and clauses pairs with condition and operation to which val, is passed as first argument. All conditions are tried and for truthy conditions the operation is executed. Returns the value mutated if any condition is truthy.


spork/misc/cond->> macro source

(cond->> val & clauses)

Threading conditional macro. It takes val to mutate, and clauses pairs of condition and operation to which val, is passed as last argument. All conditions are tried and for truthy conditions the operation is executed. Returns mutated value if any condition is truthy.


spork/misc/dedent function source

(dedent & xs)

Remove indentation after concatenating the arguments. Works by removing leading whitespace, and then removing that same pattern of whitespace after new lines.


spork/misc/defs macro source

(defs & bindings)

Defines many constants as in let bindings, but without creating a new scope.


spork/misc/dfs function source

(dfs data visit-leaf &opt node-before node-after get-children seen)

Do a depth first, pre-order traversal over a data structure. Also allow for callbacks before and after visiting the children of a node. Also allow for a custom get-children function to change traversal as needed. Will detect cycles if an empty table is passed as the seen parameter, which is used to cache values that have been visited.


spork/misc/do-def macro source

(do-def c d & body)

Convenience macro for defining constant named c with value d before body and returning it after evaluating body, that presumably modifies the content referred to by c. For example, a buffer, table or array.


spork/misc/do-var macro source

(do-var v d & body)

Convenience macro for defining variable named v with value d before body and returning it after evaluating body, that presumably modifies v.


spork/misc/format-table function source

(format-table buf-into data &opt columns header-mapping column-mapping)

Same as print-table but pushes table into a buffer.


spork/misc/gett macro source

(gett ds & keyz)

Recursive macro (get). Similar to get-in, but keyz is variadic.


spork/misc/insert-sorted function source

(insert-sorted arr <? & xs)

Insert elements in arr such that it remains sorted by the comparator. If arr is not sorted beforehand, the results are undefined. Returns arr.


spork/misc/insert-sorted-by function source

(insert-sorted-by arr f & xs)

Insert elements in arr such that it remains sorted by the value returned when f is called with the element, comparing the values with <. If arr is not sorted beforehand, the results are undefined. Returns arr.


spork/misc/int->string function source

(int->string int &opt base)

Stringify an integer in a particular base. Defaults to decimal (base 10).


spork/misc/int/ function source

(int/ & xs)

Perform integer division.


spork/misc/log macro source

(log level & args)

Print to a dynamic binding stream if that stream is set, otherwise do nothing. Evaluate to nil. For example, (log :err "value error: %V" my-value) will print to (dyn :err) only if (dyn :err) has been set.


spork/misc/make macro source

(make prototype & pairs)

Convenience macro for creating new table from even number of kvs pairs in variadic pairs arguments and setting its prototype to prototype. Factory function for creating new objects from prototypes.


spork/misc/make-id function source

(make-id &opt prefix)

Create a random, printable keyword id with 10 bytes of entropy with an optional prefix.


spork/misc/map-keys function source

(map-keys f data)

Returns new table with function f applied to data's keys recursively.


spork/misc/map-keys-flat function source

(map-keys-flat f data)

Returns new table with function f applied to data's keys without recursing.


spork/misc/map-vals function source

(map-vals f data)

Returns new table with function f applied to data's values.


spork/misc/merge-sorted function source

(merge-sorted a b &opt <?)

Merges two sorted arrays so that the result remains sorted, using an optional comparator. If no comparator is given, < is used.


spork/misc/merge-sorted-by function source

(merge-sorted-by a b f)

Merges two sorted arrays so that result remains sorted when f is called on each element, comparing the values with <.


spork/misc/penultimate function source

(penultimate xs)

Get the second-to-last element from an indexed data structure.


spork/misc/print-table function source

(print-table data &opt columns header-mapping column-mapping)

Iterate through the rows of a data structure and print a table in a human readable way, with padding and heading information. Can optionally provide a function used to print a row, as well as optionally select column keys for each row. Lastly, a header-mapping dictionary can be provided that changes the printed header names by mapping column keys to the desired header name. If no mapping is found, then the column key will be used as the header name. Returns nil.


spork/misc/randomize-array function source

(randomize-array arr &opt rng)

Randomizes array using the fisher-yates shuffle, takes an optional random number generator.


spork/misc/second function source

(second xs)

Get the second element from an indexed data structure.


spork/misc/select-keys function source

(select-keys data keyz)

Returns new table with selected keyz from dictionary data.


spork/misc/set* macro source

(set* tgts exprs)

Parallel set function. Takes a list of targets and expressions, evaluates all the expressions, and then assigns them to the targets. Each target can be a variable or a 2-tuple, just like in the normal set special form.


spork/misc/string->int function source

(string->int str &opt base)

Parse an integer in the given base. Defaults to decimal (base 10). Differs from scan-number in that this does not recognize floating point notation.


spork/misc/table-filter function source

(table-filter pred dict)

Filter a key-value structure into a table. Semantics are the same as for built-in filter, except that pred takes two arguments (key and value). Does not consider prototypes.


spork/misc/third function source

(third xs)

Get the third element from an indexed data structure.


spork/misc/trim-prefix function source

(trim-prefix prefix str)

Trim the specified prefix of a string if it has one


spork/misc/trim-suffix function source

(trim-suffix suffix str)

Trim the specified suffix of a string if it has one


spork/misc/until macro source

(until cnd & body)

Repeat body while the cnd is false. Equivalent to (while (not cnd) ;body).


spork/misc/vars macro source

(vars & bindings)

Defines many variables as in let bindings, but without creating a new scope.


spork/msg/make-proto function source

(make-proto stream &opt pack unpack)

Create both a send an recv function from a stream, as with make-send and make-recv.


spork/msg/make-recv function source

(make-recv stream &opt unpack)

Get a function that, when invoked, gets the next message from a readable stream. Provide an optional unpack function that will parse the received buffer.


spork/msg/make-send function source

(make-send stream &opt pack)

Create a function that when called with a msgs sends that msg. Provide an optional pack function that will convert a message to a string.


spork/netrepl/client function source

(client &opt host port name)

Connect to a repl server. The default host is "127.0.0.1" and the default port is "9365".


spork/netrepl/default-host string source

Default host to run server on and connect to.


spork/netrepl/default-port string source

Default port to run the net repl.


spork/netrepl/server function source

(server &opt host port env cleanup welcome-msg)

Start a repl server. The default host is "127.0.0.1" and the default port is "9365". Calling this will start a TCP server that exposes a repl into the given env. If no env is provided, a new env will be created per connection. If env is a function, that function will be invoked with the name and stream on each connection to generate an environment. cleanup is an optional function that will be called for each stream after closing if provided. welcome-msg is an optional string or function (welcome-msg client-name) to generate a message to print for the client on connection.


spork/netrepl/server-single function source

(server-single &opt host port env cleanup welcome-msg)

Short-hand for serving up a a repl that has a single environment table in it. env must be a proper env table, not a function as is possible in netrepl/server.


spork/path/abspath function source

(posix/abspath path)

Coerce a path to be absolute.


spork/path/abspath? function source

(posix/abspath? path)

Check if a path is absolute.


spork/path/basename function source

(posix/basename path)

Gets the base file name of a path.


spork/path/delim string source

Platform delimiter


spork/path/dirname function source

(posix/dirname path)

Gets the directory name of a path.


spork/path/ext function source

(ext path)

Get the file extension for a path.


spork/path/join function source

(posix/join & els)

Join path elements together.


spork/path/normalize function source

(posix/normalize path)

Normalize a path. This removes . and .. in the path, as well as empty path elements.


spork/path/parts function source

(posix/parts path)

Split a path into its parts.


spork/path/posix/abspath function source

(posix/abspath path)

Coerce a path to be absolute.


spork/path/posix/abspath? function source

(posix/abspath? path)

Check if a path is absolute.


spork/path/posix/basename function source

(posix/basename path)

Gets the base file name of a path.


spork/path/posix/delim string source

Platform delimiter


spork/path/posix/dirname function source

(posix/dirname path)

Gets the directory name of a path.


spork/path/posix/ext function source

(ext path)

Get the file extension for a path.


spork/path/posix/join function source

(posix/join & els)

Join path elements together.


spork/path/posix/normalize function source

(posix/normalize path)

Normalize a path. This removes . and .. in the path, as well as empty path elements.


spork/path/posix/parts function source

(posix/parts path)

Split a path into its parts.


spork/path/posix/relpath function source

(posix/relpath source target)

Get the relative path between two subpaths.


spork/path/posix/sep string source

Platform separator


spork/path/relpath function source

(posix/relpath source target)

Get the relative path between two subpaths.


spork/path/sep string source

Platform separator


spork/path/win32/abspath function source

(win32/abspath path)

Coerce a path to be absolute.


spork/path/win32/abspath? function source

(win32/abspath? path)

Check if a path is absolute.


spork/path/win32/basename function source

(win32/basename path)

Gets the base file name of a path.


spork/path/win32/delim string source

Platform delimiter


spork/path/win32/dirname function source

(win32/dirname path)

Gets the directory name of a path.


spork/path/win32/ext function source

(ext path)

Get the file extension for a path.


spork/path/win32/join function source

(win32/join & els)

Join path elements together.


spork/path/win32/normalize function source

(win32/normalize path)

Normalize a path. This removes . and .. in the path, as well as empty path elements.


spork/path/win32/parts function source

(win32/parts path)

Split a path into its parts.


spork/path/win32/relpath function source

(win32/relpath source target)

Get the relative path between two subpaths.


spork/path/win32/sep string source

Platform separator


spork/pgp/hex->word function source

(hex->word hex position)

Returns pgp word for hex string <100


spork/pgp/hexs->words function source

(hexs->words hex-string)

Returns an array of pgp words for arbitrary long string of hexs. Sanitizes out the whitespace from hex-string.


spork/pgp/word->hex function source

(word->hex word)

Returns a hex number as string for the pgp word.


spork/pgp/word-list struct source

Mapping from hex string < 100 to pgp words. One for odd and one for even position.


spork/pgp/words->hexs function source

(words->hexs words-string)

Returns an array of hexs from the string with pgp words.


spork/randgen/*rng* keyword source

RNG used to generate random numbers


spork/randgen/rand-cdf function source

(rand-cdf cdf)

Pick a random index, weighted by a discrete cumulative distribution function.


spork/randgen/rand-cdf-path macro source

(rand-cdf-path cdf & paths)

Execute one of the paths randomly given a discrete distribution as a CDF


spork/randgen/rand-gaussian function source

(rand-gaussian &opt m sd)

Get a random sample from the standard Gaussian distribution. Optionall specify the mean m and the standard deviation sd.


spork/randgen/rand-index function source

(rand-index xs)

Get a random numeric index of an indexed data structure


spork/randgen/rand-int function source

(rand-int start end)

Get a random integer in a range [start, end) that is approximately uniformly distributed


spork/randgen/rand-path macro source

(rand-path & paths)

Execute one of the paths randomly with uniform distribution


spork/randgen/rand-uniform function source

(rand-uniform)

Get a random number uniformly between 0 and 1


spork/randgen/rand-value function source

(rand-value xs)

Get a random value of an indexed data structure


spork/randgen/rand-weights function source

(rand-weights weights)

Pick a random index given a set of weights


spork/randgen/rand-weights-path macro source

(rand-weights-path weights & paths)

Execute one of the paths randomly given a discrete distribution as a set of weights


spork/randgen/sample-n function source

(sample-n f n)

Generate n samples based on the random sampler f.


spork/randgen/set-seed function source

(set-seed seed)

Sets the RNG seed for execution


spork/randgen/weights-to-cdf function source

(weights-to-cdf weights)

Convert an array of weights to a discrete cdf that can be more efficiently used to take a weighted random choice


spork/rawterm/begin cfunction source

(rawterm/begin &opt on-winch)

Begin raw terminal functionality. Return a stream that can be read from to get input.


spork/rawterm/buffer-traverse cfunction source

(rawterm/buffer-traverse bytes index delta &opt skip-zerowidth)

Move to a new position in a buffer from index by incrementing by delta codepoints. Can also skip zero-width codepoints if desired.


spork/rawterm/ctrl-z cfunction source

(rawterm/ctrl-z)

A handler that a user can use to handle ctrl-z from input to suspend the current process.


spork/rawterm/end cfunction source

(rawterm/end)

End raw terminal functionality.


spork/rawterm/getch cfunction source

(rawterm/getch &opt into)

Get a byte of input from stdin, without blocking if possible. Returns a buffer.


spork/rawterm/isatty cfunction source

(rawterm/isatty)

Check if the current stdin is a tty.


spork/rawterm/monowidth cfunction source

(rawterm/monowidth bytes &opt start-index end-index)

Measure the monospace width of a string.


spork/rawterm/rune-monowidth cfunction source

(rawterm/rune-monowidth rune)

Get the monospace width of a rune. Returns either 0, 1, or 2.


spork/rawterm/size cfunction source

(rawterm/size)

Get the number of rows and columns visible in the terminal as tuple [rows cols]


spork/rawterm/slice-monowidth cfunction source

(rawterm/slice-monowidth bytes columns &opt start-index into)

Get a byte slice that will fit into a number of columns.


spork/regex/compile function source

(compile pattern)

Compile a subset of regex to a PEG if pattern is a string. If pattern is a PEG, will return the PEG as is.


spork/regex/find function source

(find reg text &opt start)

Similar to peg/find, but for regexes.


spork/regex/find-all function source

(find-all reg text &opt start)

Similar to peg/find-all, but for regexes.


spork/regex/match function source

(match reg text &opt start)

Similar to peg/match, but for regexes.


spork/regex/peg core/peg source

Peg used to generate peg source code from a regular expression string.


spork/regex/replace function source

(replace reg rep text &opt start)

Similar to peg/replace, but for regexes.


spork/regex/replace-all function source

(replace-all reg rep text &opt start)

Similar to peg/replace-all, but for regexes.


spork/regex/source function source

(source pattern)

Compile a subset of regex to PEG source code.


spork/rpc/client function source

(client &opt host port name)

Create an RPC client. The default host is "127.0.0.1" and the default port is "9366". Returns a table of async functions that can be used to make remote calls. This table also contains a :close function that can be used to close the connection.


spork/rpc/default-host string source

Default host to run server on and connect to.


spork/rpc/default-port string source

Default port to run the net repl.


spork/rpc/server function source

(server functions &opt host port workers-per-connection)

Create an RPC server. The default host is "127.0.0.1" and the default port is "9366". Also must take a dictionary of functions that clients can call.


spork/schema/make-predicate function source

(make-predicate schema)

Generate a function that can be used to validate a data structure. This is the function form of predicate.


spork/schema/make-validator function source

(make-validator schema)

Generate a function that can be used to validate a data structure. This is the function form of validator.


spork/schema/predicate macro source

(predicate pattern)

Make a validation predicate given a certain schema.


spork/schema/validator macro source

(validator pattern)

Make a validation function of one argument. A validation function will throw an error on validation failure, otherwise, it will return the argument.


spork/services/*current-manager* keyword source

The currently running service manager, if there is one


spork/services/*current-service* keyword source

The currently running service, if there is one


spork/services/add-service function source

(add-service service-name main-function & args)

Spawn a service


spork/services/all-services function source

(all-services)

Get a list of running services


spork/services/get-manager function source

(get-manager)

Get the current manager. If no manager exists, create one.


spork/services/get-service function source

(get-service)

Get the current service. If not in a service, raise an error


spork/services/make-manager function source

(make-manager &opt log-dir)

Group a number of fibers into a single object for structured concurrency. Also includes utilities for running services like servers in the background.


spork/services/print-all function source

(print-all &opt filter-fn)

Print a table of all running services.


spork/services/remove-service function source

(remove-service service-name)

Remove a service


spork/services/set-title function source

(set-title title)

Set a textual description of the service to describe what it is doing currently


spork/services/start-service function source

(start-service service-name)

Start or restart a service


spork/services/stop-service function source

(stop-service service-name &opt reason)

Stop a running service


spork/services/wait function source

(wait)

Once a number of services have been spawned, call wait to block the fiber until the manager is canceled. This lets a manager fiber behave as a service itself.


spork/sh/copy function source

(copy src dest)

Copy a file or directory recursively from one location to another. Expects input to be unix style paths


spork/sh/copy-file function source

(copy-file src-path dst-path)

Copy a file from source to destination. Creates all directories in the path to the destination file if they do not exist.


spork/sh/create-dirs function source

(create-dirs dir-path)

Create all directories in path specified as string including itself.


spork/sh/devnull function source

(devnull)

get the /dev/null equivalent of the current platform as an open file


spork/sh/escape function source

(escape & args)

Output a string with all arguments correctly quoted


spork/sh/exec function source

(exec & args)

Execute command specified by args returning its exit code


spork/sh/exec-fail function source

(exec-fail & args)

Execute command specified by args, fails when command exits with non-zero exit code


spork/sh/exec-slurp function source

(exec-slurp & args)

It executes args with os/spawn and throws an error if the process returns with non-zero exit code. If the process exits with zero exit code, this function trims standard output of the process and returns it. Before the function finishes, the spawned process is closed for resource control.


spork/sh/exec-slurp-all function source

(exec-slurp-all & args)

It executes args with os/spawn and returns a struct which has the following keys.

  • :out - trimmed standard output of the process
  • :err - trimmed standard error of the process
  • :status - the exit code of the process

Before the function finishes, the spawned process is closed for resource control.


spork/sh/exists? function source

(exists? path)

Check if the given file or directory exists. (Follows symlinks)


spork/sh/list-all-files function source

(list-all-files dir &opt into)

List the files in the given directory recursively. Return the paths to all files found, relative to the current working directory if the given path is a relative path, or as an absolute path otherwise.


spork/sh/make-new-file function source

(make-new-file file-path &opt mode)

Create and open a file, creating all the directories leading to the file if they do not exist, and return it. By default, open as a writable file (mode is :w).


spork/sh/rm function source

(rm path)

Remove a directory and all sub directories recursively.


spork/sh/scan-directory function source

(scan-directory dir func)

Scan a directory recursively, applying the given function on all files and directories in a depth-first manner. This function has no effect if the directory does not exist.


spork/sh/split function source

(split s)

Split a string into 'sh like' tokens, returns nil if unable to parse the string.


spork/stream/lines function source

(lines stream &named separator)

Returns a fiber that yields each line from a core/stream value. If separator is not specified, the default separator is \n. After the fiber yields the last line, it returns nil. If the fiber is resumed after the stream is closed or after the fiber returns nil, an error is thrown.


spork/tarray/buffer cfunction

(tarray/buffer array|size)

Return typed array buffer or create a new buffer.


spork/tarray/copy-bytes cfunction

(tarray/copy-bytes src sindex dst dindex &opt count)

Copy count elements (default 1) of src array from index sindex to dst array at position dindex memory can overlap.


spork/tarray/length cfunction

(tarray/length array|buffer)

Return typed array or buffer size.


spork/tarray/new cfunction

(tarray/new type size &opt stride offset tarray|buffer)

Create new typed array.


spork/tarray/properties cfunction

(tarray/properties array)

Return typed array properties as a struct.


spork/tarray/slice cfunction

(tarray/slice tarr &opt start end)

Takes a slice of a typed array from start to end. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the typed array. By default, start is 0 and end is the size of the typed array. Returns a new janet array.


spork/tarray/swap-bytes cfunction

(tarray/swap-bytes src sindex dst dindex &opt count)

Swap count elements (default 1) between src array from index sindex and dst array at position dindex memory can overlap.


spork/tasker/all-tasks function source

(all-tasks tasker &opt detailed)

Get an array of all task ids for which there is still data on disk. If detailed is truthy, return full task metadata instead of ids.


spork/tasker/cancel-task function source

(cancel-task tasker task-id)

Cancel a queued or running task.


spork/tasker/close-queues function source

(close-queues tasker)

Prevent any tasks from being added to queues. When an executor finishes its current job, if there are any, it will terminate. When all executors complete, the call to run-executors will complete.


spork/tasker/default-expiration number source

Default expiration time (1 day)


spork/tasker/default-priority number source

Default task priority


spork/tasker/default-task-directory string source

Default location of task records


spork/tasker/err-file-name string source

Name of the file for logging errors


spork/tasker/max-priority number source

Maximum allowed priority (lower priority tasks will execute first)


spork/tasker/min-priority number source

Minimum allowed priority (lower priority tasks will execute first)


spork/tasker/new-tasker function source

(new-tasker &opt task-directory queues queue-size)

Create queues and various settings to run tasks. Create a new tasker table.


spork/tasker/out-file-name string source

Name of the file for general logging


spork/tasker/queue-task function source

(queue-task tasker argv &opt note priority qname timeout expiration input)

Add a task specification to a queue. Supply an argv string array that will be used to invoke a subprocess. The optional note parameter is just a textual note for task tracking. The priority parameter should be an integer between 0 and 9 inclusive, default is 4. Lower priority jobs in the same queue will be executed by higher priority. Use input to pass in generic, unstructured input to a task.


spork/tasker/run-cleanup function source

(run-cleanup tasker)

Delete old expired jobs saved on disk


spork/tasker/run-executors function source

(run-executors tasker &opt workers-per-queue pre-task post-task)

Start a number of executors to run tasks as with tasker/spawn-executors, and then wait for all executors to complete.


spork/tasker/spawn-executors function source

(spawn-executors tasker &opt qnames workers-per-queue pre-task post-task)

Start a number of executors to run tasks. Tasks can be added to a queue by calling queue-task. A single tasker object can make multiple calls to spawn-executors.


spork/tasker/statuses tuple source

A tuple of all possible statuses that a task can have.


spork/tasker/task-file function source

(task-file tasker task-id &opt file-name)

Get a log file for a path. By default, will get a path to out.log.


spork/tasker/task-meta-name string source

Name of the task metadata file


spork/tasker/task-status function source

(task-status tasker task-id)

Look up the status of a given task by id.


spork/temple/add-loader function source

(add-loader)

Adds the custom template loader to Janet's module/loaders and update module/paths.


spork/temple/base-env table source

Base environment for rendering


spork/temple/compile function source

(compile str)

Compile a Temple template into a function which will return a rendered buffer.

The resulting function should receive the template arguments in the &keys format.


spork/temple/create function source

(create source &opt where)

Compile a template string into a function. Optionally provide a location where the source is from to improve debugging. Returns the template function.


spork/test/assert macro source

(assert x &opt e)

Overrides the default assert with some nice error handling.


spork/test/assert-docs function source

(assert-docs path)

Assert that all symbols have proper docstring when module on the path is required.


spork/test/assert-error macro source

(assert-error msg & forms)

Test passes if forms error.


spork/test/assert-no-error macro source

(assert-no-error msg & forms)

Test passes if forms do not error.


spork/test/assert-not macro source

(assert-not x &opt e)

Invert assert.


spork/test/capture-stderr macro source

(capture-stderr & body)

Runs the form and captures stderr. Returns tuple with result of the form and a string with captured stderr.


spork/test/capture-stdout macro source

(capture-stdout & body)

Runs the form and captures stdout. Returns tuple with result of the form and a string with captured stdout.


spork/test/end-suite function source

(end-suite)

Ends test suite, prints summary and exits if any tests have failed.


spork/test/start-suite function source

(start-suite &opt name)

Starts test suite.


spork/test/suppress-stderr macro source

(suppress-stderr & body)

Suppreses stderr from the body


spork/test/suppress-stdout macro source

(suppress-stdout & body)

Suppreses stdout from the body


spork/test/timeit macro source

(timeit form &opt tag)

Time the execution of form using os/clock before and after, and print the result to stdout. Returns result of executing form. Uses tag (default "Elapsed time:") to tag the printout.


spork/test/timeit-loop macro source

(timeit-loop head & body)

Similar to loop, but outputs performance statistics after completion. Additionally defines a :timeout verb to iterate continuously for a given number of seconds. If the first form of body is a bytes, it will be taken as a custom tag.


spork/utf8/decode-rune cfunction source

(utf8/decode-rune buf &opt start)

Read a UTF-8 encoded Unicode codepoint from the buffer which starts at the given index. Returns a tuple [value width], where width = number of bytes consumed. If at the end of buffer or the buffer contains malformed UTF-8, returns [nil 0].


spork/utf8/encode-rune cfunction source

(utf8/encode-rune rune &opt buf)

Encode a Unicode codepoint into the end of a buffer.


spork/utf8/prefix->width cfunction source

(utf8/prefix->width c)

Given the first byte in an UTF-8 sequence, get the number of bytes that the codepoint sequence takes up, including the prefix byte.


spork/zip/add-bytes cfunction source

(zip/add-bytes writer path data &opt comment flags)

Add a byte sequence to the zip writer.


spork/zip/add-file cfunction source

(zip/add-file writer path filename &opt comment flags)

Add a file to the zip writer.


spork/zip/compress cfunction source

(zip/compress bytes &opt level into)

Compress data and write to a buffer. Different compression levels can be used - higher compression levels trade smaller output with longer compression times. Returns into. If into not provided, a new buffer is created.


spork/zip/decompress cfunction source

(zip/decompress bytes &opt into)

Decompress data and write to a buffer. If an into buffer is not provided, a new buffer will be created.


spork/zip/extract cfunction source

(zip/extract reader idx-or-filename &opt into flags)

Extract a file from the zip archive, either to memory or to a file on disk.


spork/zip/file-directory? cfunction source

(zip/file-directory? reader idx)

Check if a file index is a directory.


spork/zip/file-encrypted? cfunction source

(zip/file-encrypted? reader idx)

Check if a file is encrypted inside an archive.


spork/zip/file-supported? cfunction source

(zip/file-supported? reader idx)

Check if a file is supported with this verstion of miniz.


spork/zip/get-filename cfunction source

(zip/get-filename reader idx)

Convert a file index index in the archive to a filename.


spork/zip/locate-file cfunction source

(zip/locate-file reader path &opt comment flags)

Get the index of a particular filename in the archive.


spork/zip/read-bytes cfunction source

(zip/read-bytes bytes &opt flags)

Read a byte sequence as a zip archive. Returns a new zip reader.


spork/zip/read-file cfunction source

(zip/read-file filename &opt flags)

Read a file as a zip archive. Returns a new zip reader.


spork/zip/reader-close cfunction source

(zip/reader-close reader)

Close a reader and free related memory.


spork/zip/reader-count cfunction source

(zip/reader-count reader)

Get the number of files inside the zip archive. The files can be indexed


spork/zip/stat cfunction source

(zip/stat reader idx)

Get stat information of file. Returns a new struct with the following fields:

  • :index - integer index in master directory
  • :version-made-by - zip verstion
  • :version-needed - zip version needed to unzip
  • :bit-flag
  • :method - compression method
  • :time - file time
  • :crc32 - checksum of file contents
  • :comp-size - size of file when compressed
  • :uncomp-size - size of file when uncompressed
  • :filename
  • :comment
  • :internal-attr
  • :external-attr

spork/zip/version cfunction source

(zip/version)

Get the version string of the underlying miniz library.


spork/zip/write-buffer cfunction source

(zip/write-buffer)

Create a new zip archive writer that write to memory.


spork/zip/write-file cfunction source

(zip/write-file dest-path)

Create a new zip archive writer that will write into an archive file.


spork/zip/writer-close cfunction source

(zip/writer-close writer)

Close a ZipWriter.


spork/zip/writer-finalize cfunction source

(zip/writer-finalizer writer)

Finalize a writer, writing any zip files to disk. Return the writer.