Skip to content

Commit

Permalink
now linting again
Browse files Browse the repository at this point in the history
  • Loading branch information
mike dupont committed Oct 17, 2024
1 parent b859cba commit 41fd69a
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 60 deletions.
30 changes: 18 additions & 12 deletions clinic_report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export interface ClinicFunctions {
//import { missing } from "./missing.ts"
import { associate_cache, save_cache } from "./cache.ts"
import type { Struct } from "./cache.ts"
import type { Introspector,CallbackOutput, iFrame,Tree,StringToTreeCallback,MaybeTree } from "./introspector.ts";
import * as fs from 'node:fs';
import type { Introspector,CallbackOutput, iFrame,
//Tree,
StringToTreeCallback,MaybeTree } from "./introspector.ts";
//import * as fs from 'node:fs';

function process_chunk(line:string,callback:Introspector):MaybeTree
{
Expand Down Expand Up @@ -58,16 +60,18 @@ function frame_test(f: iFrame,parent:string,callback:Introspector){
_array: iFrame[],
parent_name:string,
callback:Introspector): iFrame {

//console.log("reportchild",callback);
if(callback.debug) {
callback.debug("report child");
}
if(!callback.filter_current_value(currentValue))
// if (! currentValue.name.includes("o1js"))
{
return {value: 0} as iFrame // return a new object with just the value
}
const name = parent_name + "|" +currentValue.name;
if (callback.filter_current_value){
if(!callback.filter_current_value(currentValue))
// if (! currentValue.name.includes("o1js"))
{
return {value: 0} as iFrame // return a new object with just the value
}
}
const name = parent_name + "|" +currentValue.name;
//console.log( "previousValue", JSON.stringify(previousValue).length);
//console.log("previousValue.name",previousValue.name);
// console.log("currentValue",JSON.stringify(currentValue).length);
Expand Down Expand Up @@ -147,7 +151,7 @@ function createRunningSumFunctor(
};
}

function process_flame_report(filename:string, data:string, callback:Introspector) {
function process_flame_report(_filename:string, data:string, callback:Introspector) {
if(callback.debug) {
callback.debug("flame");
}
Expand All @@ -163,7 +167,9 @@ function createProcessor(filename:string,callback:Introspector) {
}
}

function isp_clinic_flame_report(report_url:string, data:Struct, callback:Introspector):string {
function isp_clinic_flame_report(report_url:string,
data:Struct,
callback:Introspector):string {
//console.log("file: " + data.newpath);
if(callback.debug) {
callback.debug("ispflame");
Expand All @@ -181,7 +187,7 @@ const clinic_functions: ClinicFunctions = {
'clinic-flame': isp_clinic_flame_report
}

function isp_clinic_missing_report(report_url:string, data:Struct, callback:Introspector):string {
function isp_clinic_missing_report(_report_url:string, data:Struct, _callback:Introspector):string {
console.log("missing"+ data);
return "missing"
}
Expand Down
129 changes: 112 additions & 17 deletions filter.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,107 @@
import { test_driver } from "./test_driver.ts";
import type { Introspector,CallbackOutput,CallbackInput,iFrame } from "./introspector.ts";
import * as dataForge from "npm:[email protected]"
import type { Introspector,CallbackOutput,CallbackInput,iFrame,Accumulator,Accumulated } from "./introspector.ts";
//import type * as dataForge from "npm:[email protected]"

export function add_to_frame(_results:string,
name:string,
value:string):void {
console.log(name,value);
}
// export function add_to_frame(_results:string,
// name:string,
// value:string):void {
// console.log(name,value);
// }

export function find_calls(_event:string,
_filter:string):void {
}

//(event: any) => DataFrame<number, never>

// Define the type for the accumulator instance
interface NameCount {
name: string;
count: number;
}

// Create a singleton functor with many properties
function createAccumulator(): Accumulator {
const resultsList: Accumulated[] = [];

// the function returned
function accumulator(value: Accumulated): Accumulated {
resultsList.push(value);
return value;
}

function getResults(): Accumulated[] {
return resultsList;
}

function renderHtml(): string {
const html = resultsList.map((result) => `<p>${result}</p>`).join('');
return `<html><body>${html}</body></html>`;
}

function renderJson(): string {
return JSON.stringify(resultsList, null, 2);
}

function renderConsole(): void {
console.log('Accumulator Results:');
resultsList.forEach((result) => console.log(result));
}

accumulator.results = getResults;
accumulator.renderHtml = renderHtml;
accumulator.renderJson = renderJson;
accumulator.renderConsole = renderConsole;

return accumulator;
}

// Create a singleton functor with many properties
function createAccumulated(value:NameCount): Accumulated {
let _result: NameCount=value;
function accumulator(value: NameCount): NameCount {
_result = value;
return value;
}
function getResult(): NameCount {
return _result;
}

function renderHtml(): string {
const html = `<p>${JSON.stringify(_result)}</p>`;
return `<html><body>${html}</body></html>`;
}

function renderJson(): string {
return JSON.stringify(_result, null, 2);
}

function renderConsole(): void {
console.log('Accumulator Results:');
console.log(_result);
}

accumulator.results = getResult;
accumulator.renderHtml = renderHtml;
accumulator.renderJson = renderJson;
accumulator.renderConsole = renderConsole;

return accumulator;
}


// Create a singleton instance of the accumulator
const nameCountAccumulator = createAccumulator();


export function test_frame():void{
console.log("hello test frame");
const empty_frame = new dataForge.DataFrame([]);

// var data_list = [];
//var empty_frame1 = new dataForge.DataFrame([]);

function filter_function_name(frame:iFrame):boolean {
console.log("filter"+frame);
function filter_function_name(_frame:iFrame):boolean {
//console.log("filter"+frame);
return true;
}

Expand All @@ -32,18 +114,31 @@ export function test_frame():void{
//function visit_function_name(function_name:string, function_value:any):void {
// add_to_frame(empty_frame,function_name, function_value);
//}
return function returnframe() { return empty_frame; };
};

return {name:"fixme"};
};
visitor.filter_current_value= filter_function_name; // save part of the callback

visitor.accumulator = createAccumulator();
visitor.debug= function(x:string):CallbackOutput{
console.log("debug",x);

//console.log("debug",x);
//const callback =foo;
const a = createAccumulated({count:1,name:x});
//a[x]=1;
//let newRow = new dataForge.DataFrame([a]);
//empty_frame1 = empty_frame1.concat(newRow);
visitor.accumulator(a);

//empty_frame.count()
//console.log("frame count",empty_frame.count());
return {name:x};
}

//console.log("frame count before",empty_frame);

// console.log("frame count",empty_frame1.count());
test_driver(visitor);

console.log("frame count",empty_frame.count());
//var empty_frame1 = new dataForge.DataFrame(data_list);
//console.log("frame count after",empty_frame);
//console.log("frame count",empty_frame1.count());
}// test frame

2 changes: 1 addition & 1 deletion functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

// delete me
import type { Callback } from "./introspector.ts";
export interface Functions {
[key: string]: Callback;
Expand Down
50 changes: 45 additions & 5 deletions introspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export interface TreeNode {
export interface Tree {
merged: TreeNode;
unmerged: TreeNode;
codeAreas: any;
//codeAreas: any;
appName: string;
pathSeparator: string;
}

class DataTree {
export class DataTree {
merged!: TreeNode;
unmerged!: TreeNode;
codeAreas: any;
// codeAreas: any;
appName!: string;
pathSeparator!: string;
mergedNodes!: TreeNode[];
Expand All @@ -70,20 +70,60 @@ class DataTree {
}


export interface Accumulated {
//(value: T): T;
//result: () => T;
renderHtml: () => string;
renderJson: () => string;
renderConsole: () => void;
}

// Define the interface for the accumulator
export interface Accumulator {
(value: Accumulated): Accumulated;
results: () => Accumulated[];
renderHtml: () => string;
renderJson: () => string;
renderConsole: () => void;
}

// // Create a singleton instance of the accumulator
// const accumulator = createAccumulator();

// // Use the accumulator
// accumulator(10);
// accumulator(20);
// accumulator(30);

// // Retrieve the results via the properties
// console.log('Results:', accumulator.results());

// // Render the results in different formats
// console.log('HTML:');
// console.log(accumulator.renderHtml());

// console.log('JSON:');
// console.log(accumulator.renderJson());

// console.log('Console:');
// accumulator.renderConsole();

export type StringCallback = (x: string) => CallbackOutput;
export type FilterFunctionCallback = (function_name: iFrame) => boolean
//export type Example1 = (event: any) => DataFrame<number, never>;


export interface Introspector {
(): Callback;// the default function
filter_current_value: FilterFunctionCallback;
// enter_test_driver:Callback
// leave_test_driver:Callback
// wrapper_rdf:Callback
debug:StringCallback
debug:StringCallback
accumulator:Accumulator
}

export function isp_self(subj:string,callback:Introspector) :void {
export function isp_self(subj:string,_callback:Introspector) :void {
console.log("self"+ subj);
//return {name:"nope"}
}
Expand Down
21 changes: 11 additions & 10 deletions main_test1.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
//import { assertEquals } from "@std/assert";
//import { add } from "./main.ts";
import type { _Introspector,
CallbackOutput,CallbackInput } from "./introspector.ts";
//CallbackOutput,
//CallbackInput
} from "./introspector.ts";

import { test_driver } from "./test_driver.ts";
//import { test_frame } from "./filter.ts";
//import { test_driver } from "./test_driver.ts";
import { test_frame } from "./filter.ts";

function foo(a:CallbackInput):CallbackOutput
{
console.log(a);
return a;
}
// function foo(a:CallbackInput):CallbackOutput
// {
// console.log(a);
// return a;
// }

function main():void {
const callback =foo;
console.log("debug1");
const a = test_driver(callback);
const a = test_frame();
console.log("debugb",a);
}

Expand Down
Loading

0 comments on commit 41fd69a

Please sign in to comment.