Giter VIP home page Giter VIP logo

clava-flow's Introduction

Boilerplate to extend a Node:

namespace __SUB_NODE__ {
    export class Class<
        D extends Data = Data,
        S extends ScratchData = ScratchData,
    > extends __SUPER_NODE__.Class<D, S> {
        /* Add methods here */
    }

    export class Builder
        extends __SUPER_NODE__.Builder
        implements NodeBuilder<Data, ScratchData>
    {
        constructor(/* ... */) {
            super(/* ... */);
            /* ... */
        }

        buildData(data: BaseNode.Data): Data {
            return {
                ...super.buildData(data),
                /* Build data fields here */
            };
        }

        buildScratchData(scratchData: BaseNode.ScratchData): ScratchData {
            return {
                ...super.buildScratchData(scratchData),
                /* Build scratch data fields here */
            };
        }
    }

    export const TypeGuard: NodeTypeGuard<Data, ScratchData> = {
        isDataCompatible(data: BaseNode.Data): data is Data {
            if (!__SUPER_NODE__.TypeGuard.isDataCompatible(data)) return false;
            const d = data as Data;
            /* Add data checks here */
            return true;
        },

        isScratchDataCompatible(
            scratchData: BaseNode.ScratchData,
        ): scratchData is ScratchData {
            if (!__SUPER_NODE__.TypeGuard.isScratchDataCompatible(scratchData)) return false;
            const s = scratchData as ScratchData;
            /* Add scratch data checks here */
            return true;
        },
    };

    export interface Data extends __SUPER_NODE__.Data {
        /* Add data fields here */
    }

    export interface ScratchData extends __SUPER_NODE__.ScratchData {
        /* Add scratch data fields here */
    }
}

export default __SUB_NODE__;

Boilerplate to extend an Edge:

namespace __SUB_EDGE__ {
    export class Class<
        D extends Data = Data,
        S extends ScratchData = ScratchData,
    > extends __SUPER_EDGE__.Class<D, S> {
        /* Add methods here */
    }

    export class Builder
        extends __SUPER_EDGE__.Builder
        implements EdgeBuilder<Data, ScratchData>
    {
        constructor(/* ... */) {
            super(/* ... */);
            /* ... */
        }

        buildData(data: BaseEdge.Data): Data {
            return {
                ...super.buildData(data),
                /* Build data fields here */
            };
        }

        buildScratchData(scratchData: BaseEdge.ScratchData): ScratchData {
            return {
                ...super.buildScratchData(scratchData),
                /* Build scratch data fields here */
            };
        }
    }

    export const TypeGuard: EdgeTypeGuard<Data, ScratchData> = {
        isDataCompatible(data: BaseEdge.Data): data is Data {
            if (!__SUPER_EDGE__.TypeGuard.isDataCompatible(data)) return false;
            const d = data as Data;
            /* Add data checks here */
            return true;
        },

        isScratchDataCompatible(
            scratchData: BaseEdge.ScratchData,
        ): scratchData is ScratchData {
            if (!__SUPER_EDGE__.TypeGuard.isScratchDataCompatible(scratchData)) return false;
            const s = scratchData as ScratchData;
            /* Add scratch data checks here */
            return true;
        },
    };

    export interface Data extends __SUPER_EDGE__.Data {
        /* Add data fields here */
    }

    export interface ScratchData extends __SUPER_EDGE__.ScratchData {
        /* Add scratch data fields here */
    }
}

export default __SUB_EDGE__;

Boilerplate to extend a Graph:

namespace __SUB_GRAPH__ {
    export class Class<
        D extends Data = Data, 
        S extends ScratchData = ScratchData
    >  extends __SUPER_GRAPH__.Class<D, S> {
        /* Add methods here */
    }

    export class Builder extends __SUPER_GRAPH__.Builder implements GraphBuilder<Data, ScratchData> {
        constructor(/* ... */) {
            super(/* ... */);
            /* ... */
        }

        override buildData(data: BaseGraph.Data): Data {
            return {
                ...super.buildData(data),
                /* Build data fields here */
            };
        }

        override buildScratchData(scratchData: BaseGraph.ScratchData): ScratchData {
            return {
                ...super.buildScratchData(scratchData),
                /* Build scratch data fields here */
            };
        }
    }

    export const TypeGuard: GraphTypeGuard<Data, ScratchData> = {
        isDataCompatible(data: BaseGraph.Data): data is Data {
            if (!__SUPER_GRAPH__.TypeGuard.isDataCompatible(data)) return false;
            const d = data as Data;
            /* Add data checks here */
            return true;
        },

        isScratchDataCompatible(sData: BaseGraph.ScratchData): sData is ScratchData {
            if (!__SUPER_GRAPH__.TypeGuard.isScratchDataCompatible(sData)) return false;
            const s = scratchData as ScratchData;
            /* Add scratch data checks here */
            return true;
        },
    };

    export interface Data extends __SUPER_GRAPH__.Data {
        /* Add data fields here */
    }

    export interface ScratchData extends __SUPER_GRAPH__.Data {
        /* Add scratch data fields here */
    }
}

export default __SUB_GRAPH__;

clava-flow's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.