coffeescript

Jest with coffeescript jsx?

折月煮酒 提交于 2019-12-19 05:29:22
问题 How can I use Jest to test React components written in CoffeeScript + React jsx? The only CoffeeScript example provided with Jest uses plain CoffeeScript, and doesn't work with CoffeeScript + React JSX (syntax error when it reaches a < ). What I have tried first attempt: execSync // preprocessor.js var execSync = require('exec-sync'); module.exports = { process: function (src, path) { return execSync('browserify -t coffee-reactify ' + path); } }; This works, but takes too much time (a good 12

Export a class from a Coffeescript file

戏子无情 提交于 2019-12-19 05:18:58
问题 If I have a Coffeescript class defined in a separate file which I'm calling from my main script. I can make the functions within the file globally visible, but not the class. Included file is: root = exports ? this root.add = (a, b) -> return a + b class root.userModel username: 'Aaaa' name: 'Bbbb' I can access the function from my main code. How can I create the class? 回答1: Your code will indeed make userModel a global, assuming that exports is undefined and this is window . If you're having

Why vundle requires filetype off

对着背影说爱祢 提交于 2019-12-19 05:05:09
问题 On vundle's homepage, it documented that it requires filetype to be off in .vimrc: filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() I don't understand why. Since I am encountering problems with editing .coffee and .less files recently after separately-installed related plugins for them (vim-coffee-script and vim-less). My issue on vim-coffee-script 回答1: You can set filetype on after the last Vundle command: filetype off " required! set rtp+=~/.vim/bundle/vundle/ call

Node Route.get() requires callback function but got a [object undefined]

╄→гoц情女王★ 提交于 2019-12-19 04:09:42
问题 I'm utilizing Passport to create a Google OAuth2 authentication system. I'm trying to write the route files in Coffeescript for it, except for some reason I keep getting this error: D:\Programming\weebly-site\node_modules\express\lib\router\route.js:162 throw new Error(msg); ^ Error: Route.get() requires callback functions but got a [object Undefined] at D:\Programming\weebly-site\node_modules\express\lib\router\route.js:162:15 at Array.forEach (native) at Route.(anonymous function) [as get]

Infinite scroll and will_paginate appending the 'next page' of items multiple times

放肆的年华 提交于 2019-12-19 03:21:32
问题 I am following this railscast in trying to implement an infinite scroll page on my rails app. When a user scrolls down to the bottom of the page an new set of items is appended and the page extends, however it is appended to the page multiple times and the event triggers again on scrolldown even when all the items in the array have been loaded, appending the same set of items again multiple times. What I would like is to append the 'next page' of items each time a user scrolls to the bottom,

Subclassing native objects: instanceof not working properly

假装没事ソ 提交于 2019-12-18 14:38:43
问题 I'm trying to subclass the native JS Error object in CoffeeScript to get specialized error types, but i found that the instanceof does not work correctly if i don't define a constructor in the subclasses: class SimpleError extends Error class EmptyConstructorError extends Error constructor: -> class SuperConstructorError extends Error constructor: -> super new SimpleError instanceof SimpleError # -> false new EmptyConstructorError instanceof EmptyConstructorError # -> true new

Lodash Debounce not debouncing

二次信任 提交于 2019-12-18 14:15:24
问题 I'm trying to debounce a function using Lodash, and while it's invoking the function, it doesn't seem to debounce it at all. My issue doesn't seem to be the same mistake as what I've seen elsewhere on SO or Google (generally, that they're not invoking the function that _.debounce returns). My currently super-simple implementation is as follows (in Angular with CoffeeScript): s.search = -> _.debounce( s._makeSearchRequest, 1000 )() s._makeSearchRequest = -> console.log("making search request")

How to see what states are configured in AngularJS / UI-Router?

被刻印的时光 ゝ 提交于 2019-12-18 13:52:28
问题 Is there a way to see all of the states that have been set on $stateProvider ? In this case, I would like my state assignments to be distributed across many files. I would like to inspect the built states on run or config in a different file. For example: # component1.coffee angular.module('zoo').config ($stateProvider) -> $stateProvider.state 'component1', url: '/component1' template: _template controller: 'Component1Ctrl' # component2.coffee angular.module('zoo').config ($stateProvider) ->

Node.js: Configuration and routes in a different file

我是研究僧i 提交于 2019-12-18 13:00:51
问题 I am starting a new Node.js app and this time, I'm trying to organize the code correctly instead of having everything in the same file. I only have a simple setup now at server.coffee : express = require 'express' app = module.exports = express.createServer() ## CONFIGURATION ## app.configure () -> app.set 'views', __dirname + '/views' app.set 'view engine', 'jade' app.use express.bodyParser() app.use express.logger('dev') app.use express.profiler() app.use express.methodOverride() app.use

Expose a javascript api with coffeescript

好久不见. 提交于 2019-12-18 12:58:10
问题 I recently started using coffeescript and was curious what is the "right" way to expose an object that I create with Coffeescript to other javascript pages. Because of coffeescripts wrapping functionality, is it acceptable behavior to call window.coffeeObject = externalObject . Example example.coffee externalObject = method1: -> 'Return value' method2: -> 'Return method2' window.myApi = externalObject example.js -- compiled from example.coffee (function() { var externalObject; externalObject