New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fraczak/k

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fraczak/k - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

pretty.coffee

51

codes.js
// Generated by CoffeeScript 2.7.0
(function() {
var are_different, compareAs, minimize, normalize, normalizeAll, pretty, pretty_labels;
var are_different, minimize, normalize, normalizeAll;

@@ -95,49 +95,2 @@ are_different = function(classes, representatives, name1, name2, codes) {

compareAs = function(fn) {
return function(a, b) {
[a, b] = [a, b].map(fn);
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
};
};
pretty_labels = function(label_ref_map, codes, representatives) {
var labels;
return labels = Object.keys(label_ref_map).sort(compareAs(function(x) {
return x;
})).map(function(label) {
return `${pretty({
code: "ref",
ref: label_ref_map[label]
}, codes, representatives)} ${label}`;
}).join(", ");
};
pretty = function(codeExp, codes, representatives) {
var name, ref, ref1;
switch (codeExp.code) {
case "ref":
name = (ref = representatives[codeExp.ref]) != null ? ref : codeExp.ref;
if (name.startsWith(":")) {
return pretty(codes[name], codes, representatives);
} else {
return name;
}
break;
case "product":
return `{${pretty_labels(codeExp.product, codes, representatives)}}`;
case "union":
return `<${pretty_labels(codeExp.union, codes, representatives)}>`;
case "vector":
return `[${(ref1 = representatives[codeExp.ref]) != null ? ref1 : codeExp.ref}]`;
default:
return ":error";
}
};
normalize = function(label_ref_map, representatives) {

@@ -180,4 +133,4 @@ // console.log {label_ref_map, representatives}

module.exports = {minimize, pretty, normalize, normalizeAll};
module.exports = {minimize, normalize, normalizeAll};
}).call(this);
{
"name": "@fraczak/k",
"version": "1.2.2",
"version": "1.2.3",
"description": "k-language for JSON-like data transformation",

@@ -5,0 +5,0 @@ "main": "index.js",

# k-language
npm install @fraczak/k
npm install '@fraczak/k'

@@ -87,4 +87,4 @@ From javascript:

[.0, .1 max] -- [x0, [x1, x2, ...]] -> [x0, max(x1,x2,...)], i.e., recursive call
<GT.0,.1>, -- if x0 > max(x1,x2,...) then x0 else max(x1,x2,...)
-- when SNOC is not defined, e.g. the argument is a singleton vector [x0]
<GT .0, .1>, -- if x0 > max(x1,x2,...) then x0 else max(x1,x2,...)
-- when SNOC is not defined, e.g. the argument is a singleton vector [x0]
.0 -- [x0] -> x0,

@@ -106,3 +106,3 @@ >;

$ tree = <string leaf, {tree left, tree right} tree>;
$tree = <string leaf, {tree left, tree right} tree>;

@@ -148,4 +148,4 @@ Each _code_ definition starts with a `$`.

{"y": 123, "x": 432,"others": "..."} --> {"x&y":"x=432 & y=123"}
{"x":987} --> {"x&y":"only x=987"}
{"z":123} --> {"x&y":"no x nor y"}
{"x": 987} --> {"x&y":"only x=987"}
{"z": 123} --> {"x&y":"no x nor y"}
^D - to interrupt

@@ -178,3 +178,3 @@

{"x&y":"x=432 & y=123"}
{"x&y":"onlyx=987"}
{"x&y":"only x=987"}
{"x&y":"no x nor y"}

@@ -188,4 +188,4 @@

{"y": 123, "x": 432,"others": "..."}
{"x":987}
{"z":123}
{"x": 987}
{"z": 123}
####################################################

@@ -202,3 +202,3 @@

{"a" a} toJSON fromJSON
=> {"a":"a"}
=> {"a": "a"}
inc = [(),1] PLUS; 1 inc inc

@@ -205,0 +205,0 @@ => 3

// Generated by CoffeeScript 2.7.0
(function() {
//!/usr/bin/env coffee
var help, k, re, run,
var help, k, prettyCode, prettyRel, re, run,
splice = [].splice;

@@ -11,2 +11,4 @@

({prettyCode, prettyRel} = require("./pretty"));
console.log("Very! experimental repl shell for 'k-language'...");

@@ -18,2 +20,3 @@

console.log(" --c print codes");
console.log(" --r print rels");
return console.log(" --l file.k load 'file.k'");

@@ -28,3 +31,3 @@ };

return process.stdin.on('data', function(data) {
var e, file, first, i, last, len, line, ref, ref1, ref2, rest, results, todo;
var e, file, first, i, last, len, line, ref, rest, results, todo;
[first, ...rest] = data.toString("utf8").split("\n");

@@ -52,7 +55,30 @@ buffer.push(first);

results.push(console.log(JSON.stringify(run.defs, " ", 2)));
} else if (line.match(/^[ \n\t]*(?:--r)?$/)) {
results.push(console.log((function(defs, result) {
if (defs == null) {
return result;
}
return (function(prettyRel) {
var ref1, relExps, relName;
ref1 = defs.rels;
for (relName in ref1) {
relExps = ref1[relName];
result[relName] = relExps.map(prettyRel);
}
return result;
})(prettyRel.bind(null, prettyCode.bind(null, defs.codes, defs.representatives)));
})(run.defs, {})));
} else if (line.match(/^[ \n\t]*(?:--c)?$/)) {
results.push(console.log(JSON.stringify({
codes: (ref1 = run.defs) != null ? ref1.codes : void 0,
reps: (ref2 = run.defs) != null ? ref2.representatives : void 0
}, " ", 2)));
results.push(console.log((function(defs, result) {
var codeExp, codeName, ref1;
if (defs == null) {
return result;
}
ref1 = defs.codes;
for (codeName in ref1) {
codeExp = ref1[codeName];
result[codeName] = prettyCode(defs.codes, defs.representatives, codeExp);
}
return result;
})(run.defs, {})));
} else if (!line.match(/^[ \n\t]*(?:#.*)?$/)) {

@@ -59,0 +85,0 @@ try {

@@ -171,3 +171,3 @@ // Generated by CoffeeScript 2.7.0

"use strict";
var defn, e, i, j, k, label, len, len1, len2, r, ref, ref1, ref2, ref3, result;
var defn, e, i, j, k, label, len, len1, len2, r, ref, ref1, ref2, result;
if (value === void 0) {

@@ -189,5 +189,5 @@ // console.log {exp,value}

case "ref":
defn = (ref = run.defs.rels[exp.ref]) != null ? ref[0] : void 0;
defn = run.defs.rels[exp.ref];
if (defn != null) {
return run(defn, value);
return run(defn[defn.length - 1], value);
}

@@ -204,5 +204,5 @@ return builtin[exp.ref](value);

case "union":
ref1 = exp.union;
for (i = 0, len = ref1.length; i < len; i++) {
e = ref1[i];
ref = exp.union;
for (i = 0, len = ref.length; i < len; i++) {
e = ref[i];
result = run(e, value);

@@ -216,5 +216,5 @@ if (result !== void 0) {

result = [];
ref2 = exp.vector;
for (j = 0, len1 = ref2.length; j < len1; j++) {
e = ref2[j];
ref1 = exp.vector;
for (j = 0, len1 = ref1.length; j < len1; j++) {
e = ref1[j];
r = run(e, value);

@@ -229,5 +229,5 @@ if (r === void 0) {

result = {};
ref3 = exp.product;
for (k = 0, len2 = ref3.length; k < len2; k++) {
({label, exp} = ref3[k]);
ref2 = exp.product;
for (k = 0, len2 = ref2.length; k < len2; k++) {
({label, exp} = ref2[k]);
r = run(exp, value);

@@ -234,0 +234,0 @@ if (r === void 0) {

@@ -142,2 +142,14 @@ // Generated by CoffeeScript 2.7.0

}
},
{
list: {
bools: [true,
false]
}
},
{
list: {
bools: [true,
0]
}
}

@@ -144,0 +156,0 @@ ].map(function(data) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc