Giter VIP home page Giter VIP logo

rodash's Introduction

rodash

Lodash-inspired utility functions for Roku Brightscript

API Documentation

API Documentation

Example usage:

Module instantiation:

_ = rodash()

Safely find nested values without crashing on invalid intermediate objects

_.get({ a: { b: 2}}, "b")                                   
' => 2

Safely compare types for equality, capturing TYPE_MISMATCH runtime errors

_.equal(invalid, "a")
' => false

Write complex objects to the registry without manually serializing

_.regWrite("auth", "oauth", { id: 1234, token: 5678 })      
' => n/a

Read complex objects from the registry without manual deserializing

_.regRead("auth", "oauth")                                  
' => { id: 1234, token: 5678 })

Read in manifest file key/value pairs

_.getManifest()
' => { title: "My Roku App", ...}

Encode URI params simply

url = "http://www.google.com/search?" + _.uriEncodeParams({q: "log lady", oq: "log lady", sourceid: "chrome", ie: "UTF-8"})
' => "http://www.google.com/search?q=log%20lady&oq=log%20lady&sourceid=chrome&id=UTF-8"

Simple request object wraps roUrlTransfer

googleReq = _.createRequest(url, { method: "GET", body: "", headers: { "Accept", "*/*" })
' => <request object>

Synchronous execution of request

googleReq.start(true)                                       
'  => "<!doctype html><html..."

Goals:

  • reduce total lines of code, and thus complexity, in brightscript applications
  • facilitate better separation of business logic and data management
  • provide safety for common runtime errors (type mismatches, unexpected invalid objects)
  • supplement standard Brightscript components interfaces
  • be SceneGaph agnostic (not a framework)
  • have no other dependencies than the standard Brightscript components
  • thoroughly tested and documented behavior

Non-goals

  • Application architecture
  • Data modeling

Focus Areas

  • Objects: Arrays, AssociativeArrays, Nodes
  • Strings
  • Network
    • Requests
    • Uri
  • Platform
    • Registry
    • Manifest
    • Display

Building rodash.cat.brs

This will generate a single .brs file suitable for inserting into a channel source tree.

$ make dist

Building API documentation

Creating the documentation requires npm to be installed and available to the Makefile.

$ make doc

Running tests

$ export ROKU_DEV_TARGET=x.x.x.x
$ export DEV_PASSWORD=xxxx
$ make test

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.