Coder Social home page Coder Social logo

gmlodash's Introduction

GMLodash

This library is a port of the popular JavaScript library Lodash to GML 2.3. The intent is to be a utility library that enables a functional programming workflow. Not dissimillar to C#'s LINQ, or Python's List Comprehension.

Getting Started

Installation via Local Package (.yymps)

GameMaker Studio 2 allows you to import assets, including scripts and shaders, directly into your project via the "Local Package" system. From the Releases tab for this repo, download the .yymps file for the latest version. In the GMS2 IDE, load up your project and click on "Tools" on the main window toolbar. Select "Import Local Package" from the drop-down menu then import all scripts from the GMLodash package.

Installation via Copy/Paste

You can simply copy and paste the contents of GMlodash.gml into a new Script in your project.

Usage

Visit the Documentation for full documentation on the API.

Examples

_.filter([1,2,3,4], function (x) { return x <= 2; });
// => [1,2]   array -> array

var list = ds_list_create();
ds_list_add(1,2,3,4);
_.filter(list, function (x) { return x <= 2; });
// => list(1,2)    list -> list
var inventory = {
    items: [
        { itemId: "Sword", stock: 1 },
        { itemId: "Map", stock: 1 },
        { itemId: "Gem", stock: 4 }
    ]
};

/* List of the the value of property "itemId" for each element */
_.map(inventory.items, "itemId");
// => ["Sword","Map","Gem"]
/* Get the total stock of inventory */
_.reduce(inventory, "stock", 0);
// => 6
/* Some elements's itemId property = "Map" */
_.some(inventory, ["itemId","Map"]);
// => true
/* All items in the inventory have >= 1 stock (truthy evaluation) */
_.every(inventory, "stock");
// => true

Running the Unit Tests

Clone this repo, open and run the project in GameMaker: Studio. If all Unit Tests pass, a message will be printed in the Output console and the game will close. Otherwise an error will be shown on screen.

Authors

  • Zach Reedy - Primary developer - DatZach

License

This project is licensed under the MIT License - see the LICENSE file for details

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.