CoffeeScript is a little language that compiles into JavaScript. Underneath all of those embarrassing braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

learn more… | top users | synonyms

0
votes
1answer
27 views

Promises and chained calls

I've realized JS callback hell and I started looking into Promises libraries. After reading some articles I decided to start with BluebirdJS. I didn't realise how to properly use them yet, because ...
7
votes
5answers
328 views

Avoiding nested conditionals and comparing strings

I have a web page with a set of icons that are grey by default: If a user clicks one, it toggles green (.toggleClass('green')): If a user clicks a green one, ...
1
vote
1answer
23 views

Remove nodejs/browser specific code in library

I'm the maintainer of the following library on github: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxgen.coffee I want to maintain a library that works on node and in the browser, ...
9
votes
1answer
84 views

Tabbed navigation to hide and show pages

I'm new to jQuery and trying to learn how to refactor my bloated code to make it nicer and better maintainable. I have a tabbed navigation which I'm using jQuery to hide and show pages depending on ...
4
votes
1answer
38 views

Refactor array for loop result

...
8
votes
1answer
110 views

Simple CoffeeScript navigation menu

I'm using simple script to handle tab menu like this: HTML: ...
0
votes
0answers
23 views

Saving on a Backbone Collection

I am currently building a backbone view where there is a mutli select feature. Once the user selects all the records, the user hits the submit and sends all the updated models. How does this mass ...
0
votes
0answers
57 views

Currying options for Bootstrap components for use in Meteor

Bootstrap 3 helper (redacted) for displaying alerts. ...
1
vote
1answer
120 views

Inheritance in angular directive with coffeescript

Here is my solution: ...
2
votes
1answer
69 views

Backbone subviews with non-uniform layout

I have a “featured projects” view that requires its subviews conform to a non-uniform grid: one narrow column with 3 items, then one wide column with 2 items, followed by another narrow column with 3 ...
0
votes
1answer
181 views

How to improve or refactor Backbone CoffeeScript code?

how can I improve the following code mainly regarding the router, when to initialize the and fetch the collection and how I can filter the models?= Thank you ...
3
votes
2answers
73 views

How can I remove DRY violations from this event handling code?

I've got a bunch of event handlers that follow this pattern: ...
0
votes
0answers
52 views

Improvements to my binary tree written in CoffeeScript

This is my attempt at a binary tree. I'm using it only for ordering a LDAP user list. My need is for storing multiple objects, so this tree is limited to leaves that are objects (see ...
3
votes
1answer
86 views

How to refactor this series of JavaScript promises?

This is part of a class for paginating a Backbone collection. The paginateTo method is for paginating to a model id. It returns the model if it's already in the ...
2
votes
0answers
80 views

node.js Review Core class of a Javascript framework for SPA's

A few years ago I started building a tiny (~300 SLOC) JavaScript framework for scalable and maintainable Single-Page-Applications written in CoffeeScript: https://github.com/flosse/scaleApp and ...
4
votes
2answers
130 views

isRTL.coffee - A JavaScript Library to determine if a text is of Right To Left direction

I just wrote this tiny library called isRTL.coffee to determine the direction of the text. Is there any better way of doing this? original code: ...
3
votes
2answers
110 views

Fibonacci using cache

This is my simple Fibonacci implementation in CoffeeScript. What do you think? Using cache (fibResults), it's very very fast. ...
1
vote
0answers
243 views

Handling multiple Mongodb connections in Node.js (using Mongolia)

I have a situation where I have multiple objects that each needs to connect to a different mongodb uri. I am currently testing this using mongolia but the concept should be the same if I were to use ...
3
votes
2answers
459 views
0
votes
1answer
97 views

Coffeescript Review

...
1
vote
1answer
121 views

CoffeeScript: multiple changes of scope and big if/else

I just wrote this, and cleaned it up as much as I could. A couple things worry me. I change the scope of $(this) twice (and apparently don't know how to use ...
2
votes
1answer
155 views

Coffeescript Operators: use &&, ||, etc., or keyword operators?

I often use js2coffee.heroku.com to help me convert JS to CoffeeScript. Here was a line of JS I was converting. ...
2
votes
3answers
805 views

Function Is target String found in an Array of Strings in CoffeeScript

I wrote this simple function in CoffeeScript to see if elements are found in an array. ...
0
votes
1answer
1k views

Coffeescript nested if's

y = (if @projectionStyle is 'flat' then 0 else if d3.event.y < -90 -90 else if d3.event.y > 90 90 else d3.event.y) This is working now, but I ...
0
votes
1answer
274 views

Express, blade with connect-assets

I have this CoffeeScript code running here (with TZM-Blade) and would like to have your opinion on how to better optimize it. ...
1
vote
1answer
374 views

coffeescript and angular directive

I feel this is deeply inelegant, but I really want the option of classical inheritance in the future. How could this be written better. FYI animation here is from GSAP if you are curious. ...
1
vote
3answers
202 views

Cleanest way to close over a counter in CoffeeScript

I haven't spent too much time with CoffeeScript and am trying to have a simple counter: ...
1
vote
1answer
320 views

JQuery Dynamic Dropdown Update

This is based (somewhat loosely) on the code written in this railscast. I'm planning to re-use it in different places throughout the site, so I made it a bit more generic rather than based on IDs. ...
3
votes
2answers
211 views

Passing Context in CoffeeScript

I'm trying to migrate from JavaScript to CoffeeScript. However I'm not sure about the best way to optimize the code generated by js2coffee. Below is the original JavaScript source : ...
3
votes
1answer
186 views

Functional Sundaram's sieve

I wrote this Sundaram's sieve in Coffeescript to quickly generate prime numbers up to limit: ...
3
votes
0answers
93 views
2
votes
2answers
257 views

My first real JS project, simple form validation

I would really like to hear how I can improve my form validator. Next, I want to refactor it into OO and learn a testing framework like Jasmine. Some things I know I could improve Don't make it ...
3
votes
2answers
1k views

Better way to do this in coffeescript

I was actually writing this little script: ...
3
votes
2answers
3k views
2
votes
1answer
110 views

Assign local-variables in constructor

How to make this code in constructor more DRY? Is there some more concise way to assign variables passed through object? ...
3
votes
1answer
97 views

CoffeeScript method refactoring

This method is from Backbone-View. I'd like to refactor it but I don't have much experience with Coffee or JavaScript. ...
2
votes
1answer
243 views

Object Wrapper/Parameter Injection Module for CoffeeScript/JavaScript

I made an object wrapper/parameter injector and I hope it will be useful, I made it for a project I am working on but then decided to try polishing it a bit. The use case is for wrapping objects such ...
2
votes
2answers
83 views

Is there any way to make this CoffeScript code simpler / smaller

I've just started with coffeescript, and I saw http://blog.8thlight.com/uncle-bob/2012/04/20/Why-Is-Estimating-So-Hard.html which has a little programming problem, so I figured I'd do it in ...
4
votes
3answers
145 views

Can this coffeescripts method be simplified?

I'm new to coffeescripts. Can the getSum method be simplified more? Thanks ...
2
votes
1answer
475 views

PageObject implementation (CoffeeScript, CasperJS)

I'm using CasperJS and CoffeeScript for integration testing of a hobby project. Page Objects seem to be a useful abstraction. I had two major requirements: Support for node.js style callbacks - ...
0
votes
1answer
107 views

Count non-transparent pixels in a canvas

I need to count non-transparent pixels in a canvas. I am pretty sure there is a nice and elegant syntax for doing this. Note that the data returned by getImageData ...
5
votes
1answer
308 views

Project Euler question 2 in CoffeeScript

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ...
4
votes
1answer
522 views

Where is the memory leak in this scraper?

This is a scraper written in coffee-script for nodeJS. It is run in an interval (set to 5 seconds here to dramtically show the leak). Somewhere this code leaks memory. I already tried nulling a few ...
3
votes
1answer
186 views

Is there a better way to structure this in CoffeeScript?

I have this recursive function that searches an object tree structure: ...
0
votes
1answer
126 views

Is there any javascript pitfalls with this approach that I might be missing?

I have a model with a number of complex/simple properties that has a corresponding strongly typed view, that calls EditorFor to a custom editor template view for the model. One of the form's ...
2
votes
2answers
101 views

Similar but slightly different JavaScript functions

I have two very similar functions that exist mainly for syntactic sugar. ...
0
votes
1answer
105 views

Writing binding providers in CoffeeScript?

In his KnockoutJs 1.3 beta post, Steve Sanderson has an example of using Binding providers ("5. Binding providers (and hence external bindings)") where he makes a comment in the JSFiddle JavaScript ...
4
votes
3answers
140 views

Adding push to array inside the class that is being pushed

I used to mostly do this: ...
2
votes
1answer
611 views

A library written in CoffeeScript

So, I wrote this small library for fast DOM building with API tailored for CoffeeScript I feel like the code overall can be made better/smaller/faster. I am also not particularly happy about a few ...
4
votes
4answers
739 views

Short coffeescript style question

I'm going through the CoffeeScript book by Trevor Burnham, and I was curious as to what the best style is for a function I was writing. In the book the author writes the function like so: ...