Cheddar Documentation
  • Introduction
  • Syntax
  • Literals
    • Comment
    • String
    • Number
    • Array
    • Boolean
  • Mathematics
    • Addition
    • Subtraction
    • Multiplication
    • Division
    • Exponentiation
    • Remainder
    • Negation
    • Sign
    • Root
    • Bitwise AND
    • Bitwise OR
    • Bitwise XOR
    • Bitwise NOT
    • Bitwise Left Shift
    • Bitwise Right Shift
  • Variables
  • Functions
    • Defining
      • Lambda
      • Functionized Operators
      • Functionized Properties
    • Operations
      • Functional Bonding
      • Functional Composition
  • Default Operators
    • What Is
    • Instance-of
    • Actually Is
  • Control Flow
    • Conditional
    • Loops
      • For Loops
      • While Loops
  • Standard Library
    • String
      • Bytes
      • Count
      • Length
      • Match
      • Slice
      • Tail
      • Chars
      • Head
      • Lines
      • Ord
      • Split
      • Test
      • Chunk
      • Index
      • Lower
      • Reverse
      • Substitute
      • Upper
  • Developing
    • Structure
    • Primitive Objects
      • Scope
      • Class
      • Variable
      • Namespace
    • Getting Started
    • API
      • Primitives
        • string
        • number
        • array
        • bool
        • func
        • nil
Powered by GitBook
On this page
  • Creating a namespace/class
  • Adding items to your Namespace
  • Creating a Class

Was this helpful?

  1. Developing

Getting Started

PreviousNamespaceNextAPI

Last updated 4 years ago

Was this helpful?

The API is very simple to use and get started with. Depending on what you'd like to make, you're going to need to do different things. The Cheddar source code is located in the src/ directory.

Creating a namespace/class

If you wish to create a global namespace or class, make sure you've followed the instructions specified in the article. <name> represents the name of your library.

  1. Locate stdlib.es6 in the stdlib/ directory.

  2. Locate the text /** Global Libraries **/. Directly underneath this, create a line in the following format:

    STDLIB.Item("<name>", require('./ns/<name>'));
  3. Now in ns/<name>.es6. Set the contents to the template:

    export default function(cheddar) {
        return <implementation>;
    }

    <implementation> is to be replaced with your implementation. The cheddar variable, introduced by the function, is the API. <implementation> should not be wrapped as a variable. The API and it's details are described in the following sections.

Adding items to your Namespace

If you're creating a namespace. Set ns/<name>.es6 to:

export default function(cheddar) {
     return cheddar.namespace(<data>);
}

where <data> is a 2D array representing the namespace's items. The most common format of a namespace looks like:

export default function(cheddar) {
     return cheddar.namespace([
         ["<item>", cheddar.from(require("./<name>/<item>"))
     ]);
}

Creating a Class

To create a class. You can use the following format:

export default function(cheddar) {
     return class <name> extends cheddar.class {
         // Your implementation
     }
}

More information on classes will be available once more documentation is written.

Structure