Tag Archives: underscoreJS

Using Underscore.js in Node.js Apps

via Using Underscore.js in Node.js Apps.

Underscore.js is a utility library that is widely used to deal with arrays, collections and objects in JavaScript. It can be used in both frontend and backend based JavaScript applications. Usages of this library include filtering from array, mapping objects, extending objects, operating with functions and more. If you are familiar with LINQ in C#, underscore.js brings most of the capabilities of LINQ to JavaScript.

 An Awesome guide to jQuery. Available in PDF, ePub and Mobi. Click here

Node.js is a platform for building server side applications using JavaScript. While designing REST APIs in Node.jsthat interact with NoSQL databases like MongoDB, we either get an object or, a collection of objects. In most of the scenarios, we may not want to send the same object in response to the API. The data has to be mapped to the structure of the Data Transfer Object (DTO) designed for the API. This transformation would take a lot of time and energy if we do it manually. Underscore.js provides a set of handy methods that makes our job easier. In this post, we will see how to use Underscore.js and where it fits in Node.js applications.

Note: If you are new to Node.js, check Node.js Tutorial Series – Getting Started

Creating an offline app using HTML5 Cache and Underscore Template

via Create offline app using HTML5 Cache and Underscore Template.

In this article, we are going to make an application that once accessed through an internet connection would be accessible even when you are offline. The application is relatively simple – it provides the user with the ability to create new notes with title and body and remove notes he no longer needs. We are going to store the notes the user has saved in localStorage in order for the application to be accessible without internet connection.

BasketJS: A simple (proof-of-concept) script loader that caches scripts with localStorage

via basket.js – a simple script loader that caches scripts with localStorage.

This section was rendered using the micro-templating in Underscore.js. It’s just one of a number of scripts that were added to this document using basket.js when you loaded it and should now be cached in localStorage (if supported). If you visit this page again, the scripts will be loaded from there rather than being refetched. Backbone.js was also loaded and we created a new model with the name: Nyan Cat (just for funsies).

Using Cordova, HealthKit, and JavaScript, and a handful of Promises

via Gerard Davison’s Blog: How many steps did I walk yesterday: using Cordova, HealthKit, and JavaScript, and a handful of Promises.

As people who know me might know I have been playing around with various wearables for some years now, starting with a Nike Fuel Band, and also trying out products from Misfit and UP along the way. I have mostly just watched with interest as my exercise levels, and indeed sleep now we have a little one in the house, has gone up and down over time.

More recently with the arrival of HealthKit there comes a standard method of accessing this information from multiple products on the iPhone, I needed to brush up on my JavaScript for work so I decided to have a play in Cordova to build something in my spare time. One of the cool things about that Cordova community when compared to other app development frameworks is the large and healthy plugin community – and quick google and I found what I needed to support HealthKit HealthKit. This took only a small amount of patching from me to get at the information I wanted. In this blog I will just look at number of steps per day as a proxy for activity.

I am going to assume the rest of the Cordova App is in place and start with a simple wearable object which exposes a promise that allows you to check whether HealthKit is available on this platform, you might have iOS 8 but HealthKit is iPhone only. Remember that most of Cordova is interacting with a bunch of asynchronous native systems so you have to make sure you consider this as you work with it. Hence the liberal use of promises. (If you are wanting to support < iOS 8 then you will need to use a different promise library / shim) In this case I am also using the underscorejs library to create a promise who’s result won’t be calculated until it is invoked for the first time.

A project skeleton that uses node.js, express, jquery, requirejs, underscore.js, and class.js

via sent1nel/javascript-graphics-skeleton · GitHub.

A project skeleton that uses node.js, express, jquery, requirejs, underscore.js, and class.js to allow you to get started writing simple graphical applications for the browser quickly.