npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

olaf-loader

v1.1.5

Published

A Webpack loader for the Olaf language.

Downloads

158

Readme

Olaf Loader

olaf-loader is a Webpack loader for Olaf, a playful and simple programming language inspired by the beloved snowman from Disney's Frozen. With this loader, you can easily compile Olaf code into JavaScript, making it easy to integrate Olaf into your Webpack projects.

Features

  • Fun and Simple Syntax: Olaf uses intuitive and fun syntax, making programming easier and more enjoyable.
  • Seamless Webpack Integration: Use the olaf-loader to automatically compile Olaf code into JavaScript during your Webpack build process.
  • Object-Oriented Support: Define classes and use constructors to structure your code.
  • Asynchronous Handling: Simulate asynchronous operations with the wait keyword.
  • Error Handling: Olaf comes with built-in checks for common syntax errors, ensuring a smooth development experience.
  • String Interpolation: Use ${expression} for string interpolation
  • Comments Support: Both single-line (//) and multi-line (/* */) comments
  • Source Maps: Built-in source map support for better debugging
  • Constant Variables: Use freeze keyword for constants
  • Array Methods: Enhanced array operation support
  • Default Parameters: Support for default function parameters

Getting Started

Prerequisites

Installation

To install olaf-loader and use it in your Webpack project, run the following command:

npm install olaf-loader --save

Sample Code

build checkNumber(num):
    if num > 0:
        say num + " is positive."
    else:
        if num < 0:
            say num + " is negative."
        else:
            say num + " is zero."
        end
    end
end

build doubleNumbers(numbers):
    return numbers.map(number => number * 2)
end

build filterEvens(numbers):
    return numbers.filter(number => number % 2 == 0)
end

build printNumbers(arr):
    for each num in arr:
        say num
    end
end

snowman Animal:
    build constructor(name):
        this.name = name
    end

    build makeSound(sound):
        say this.name + " says " + sound
    end
end

build main:
    snowball nums = [-1, 0, 1, 5, -10]

    say "Checking Numbers:"
    for each number in nums:
        checkNumber(number) // Calling the function to check each number
    end

    say "Original Numbers:"
    printNumbers(nums) // Invoke to print original numbers

    snowball doubled = doubleNumbers(nums) // Call to doubleNumbers function
    say "Doubled Numbers:"
    printNumbers(doubled) // Invoke to print doubled numbers

    snowball evens = filterEvens(nums) // Call to filterEvens function
    say "Even Numbers:"
    printNumbers(evens) // Invoke to print even numbers

    snowball dog = new Animal("Sven")
    dog.makeSound("woof")

end

main()

Compiled JavaScript Code

function checkNumber(num) {
  if (num > 0) {
    console.log(num + " is positive.");
  } else {
    if (num < 0) {
      console.log(num + " is negative.");
    } else {
      console.log(num + " is zero.");
    }
  }
}

function doubleNumbers(numbers) {
  return numbers.map((number) => number * 2);
}

function filterEvens(numbers) {
  return numbers.filter((number) => number % 2 == 0);
}

function printNumbers(arr) {
  for (const num of arr) {
    console.log(num);
  }
}

class Animal {
  constructor(name) {
    this.name = name;
  }

  makeSound(sound) {
    console.log(this.name + " says " + sound);
  }
}

function main() {
  let nums = [-1, 0, 1, 5, -10];

  console.log("Checking Numbers:");
  for (const number of nums) {
    checkNumber(number); // Calling the function to check each number
  }

  console.log("Original Numbers:");
  printNumbers(nums); // Invoke to print original numbers

  let doubled = doubleNumbers(nums); // Call to doubleNumbers function
  console.log("Doubled Numbers:");
  printNumbers(doubled); // Invoke to print doubled numbers

  let evens = filterEvens(nums); // Call to filterEvens function
  console.log("Even Numbers:");
  printNumbers(evens); // Invoke to print even numbers

  let dog = new Animal("Sven");
  dog.makeSound("woof");
}

main();

Execution result:

Checking Numbers:
-1 is negative.
0 is zero.
1 is positive.
5 is positive.
-10 is negative.
Original Numbers:
-1
0
1
5
-10
Doubled Numbers:
-2
0
2
10
-20
Even Numbers:
0
-10
Sven says woof

Advanced Features (v1.2+)

Switch/Case Statements (blizzard/case)

Olaf supports switch/case statements using blizzard and case keywords:

blizzard(expression):
  case value1:
    // statements
    break
  case value2:
    // statements
    break
  else:
    // default statements
end

Ternary Operator (snowif)

Use the snowif keyword for ternary expressions:

snowball result = snowif(condition, valueIfTrue, valueIfFalse)

Try/Catch Error Handling (igloo/catch)

Handle errors with igloo and catch:

igloo:
  // try block
catch(error):
  // catch block
end

Arrow Functions (frost)

Arrow functions can be defined using the frost keyword:

frost double = (x) => x * 2

Module Imports/Exports (sled/export)

Import and export modules:

sled { something } from "./module.olaf"
export default myFunction

Destructuring (snowgrab)

Destructure objects easily:

snowgrab { a, b } = obj

String Interpolation (Frosty Quotes)

Use backticks and ${} for string interpolation:

say `Hello, ${name}!`

Custom Operators (flakeop)

Define custom operator functions:

flakeop add = (a, b) => a + b

VSCode Integration

Olaf supports VSCode extension for IntelliSense, Code snippets, and syntax highlighting.

GitHub VSCode Extension repository NPM registry Syntax Highlighter Extension for VSCode