kin-lang 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ // Kin Standard Library — json
2
+ export function parse(str) {
3
+ try {
4
+ return JSON.parse(str);
5
+ } catch (e) {
6
+ throw new Error("json.parse: invalid JSON string");
7
+ }
8
+ }
9
+
10
+ export function stringify(value, pretty) {
11
+ return pretty
12
+ ? JSON.stringify(value, null, 2)
13
+ : JSON.stringify(value);
14
+ }
@@ -0,0 +1,16 @@
1
+ // Kin Standard Library — math
2
+ export function add(a, b) { return a + b; }
3
+ export function subtract(a, b) { return a - b; }
4
+ export function multiply(a, b) { return a * b; }
5
+ export function divide(a, b) {
6
+ if (b === 0) throw new Error("Division by zero");
7
+ return a / b;
8
+ }
9
+ export function abs(n) { return Math.abs(n); }
10
+ export function pow(a,b) { return Math.pow(a, b); }
11
+ export function sqrt(n) { return Math.sqrt(n); }
12
+ export function square(n){ return n * n; }
13
+ export function floor(n) { return Math.floor(n); }
14
+ export function ceil(n) { return Math.ceil(n); }
15
+ export function round(n) { return Math.round(n); }
16
+ export const PI = Math.PI;
@@ -0,0 +1,12 @@
1
+ // Kin Standard Library — time
2
+ export function now() {
3
+ return Date.now();
4
+ }
5
+
6
+ export function wait(ms) {
7
+ return new Promise(resolve => setTimeout(resolve, ms));
8
+ }
9
+
10
+ export function format(timestamp) {
11
+ return new Date(timestamp).toISOString();
12
+ }