Questions tagged [co]

The Co javascript library for generator based flow-control of asynchronous tasks

Co is a javascript library for executing generators that yield asynchronous tasks, so that asynchronous code can be written in a more concise manner.

114 questions
1
vote
2 answers

How to set keyboard key using registry

Im looking for a way to write a script (hopefully in python) that remmap specific keyboard keys using the registry. For example: switching only between the enter and the space bar. In addition I would like to know if there is away to set the value…
Noa Barki
  • 51
  • 4
1
vote
1 answer

reject in promise undefined

I tried below function use co and javascript promise test, the fulfill will success return but reject not, and catch error undefined. and the flow can't continue. why? Error: > at GeneratorFunctionPrototype.next (native) at onFulfilled…
user1775888
  • 3,147
  • 13
  • 45
  • 65
1
vote
0 answers

KoaJs can only stream one connection at once

I'm trying to do something bigpipe with koajs. app.use(function* () { this.type = 'html'; this.body = myPage.stream() // returns a readable }) inside the myPage myPage.prototype.stream = function() { var readable = new…
Qiaosen Huang
  • 1,093
  • 1
  • 10
  • 25
1
vote
1 answer

how to get readStream with thunk in koa ?

I want to pipe a request in a koa controller, It's work: var s = require('through2')(); var req = http.request(url, function(res) { res.pipe(s); }) req.end(null); s.on('close', function() { console.log('has close'); }); this.body = s; But with…
elrrrrrrr
  • 894
  • 8
  • 15
1
vote
1 answer

How to make yield work with this.req.on('data') without requiring more modules?

Obviously, the reason here is because of the async nature of on('data'), and the combination of using yield, but how can I make this work? I tried "thunkifying" _this.req.on, but to no avail. I'm still getting the hang of generators, yield and…
Jan Carlo Viray
  • 11,856
  • 11
  • 42
  • 63
1
vote
1 answer

Distinction between Coroutines and Generators in Koa context?

The distinction of between Coroutines and Generators is blurry for me. I'd appreciate it if someone could read the article Callbacks vs Coroutines - A look at callbacks vs generators vs coroutines" at…
JLS
  • 691
  • 1
  • 6
  • 10
1
vote
1 answer

Why does thunkify / yield always return an array?

I have a thunk called logInline (adapted from the Co documentation). I notice the thunkified get always seems to yield an array. Is this by design? Is it thunkify doing this, or is it a standard part of yield? var co = require('co'), get =…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
1
vote
2 answers

How can get x and y position of an image in android on onCreate?

I want current X & Y co ordinates of an ImageView on onCreate of Activity, is there any solution for the same ? Please share your idea on same.
Hiren Patel
  • 52,124
  • 21
  • 173
  • 151
0
votes
0 answers

how to implement this logic in mips

a='Z' if ('A'
Rama Zain
  • 5
  • 3
0
votes
0 answers

Error in chol.default(Bmat) : the leading minor of order 34 is not positive definite

library(CCA) library(plyr) head(tobacco_clr$data) table(tobacco_clr$data) table(tobacco_clr$H) x <- tobacco_clr$data dim(x) H <- tobacco_clr$H dim(H) cca.tobacco <- cc(x,H) Show this result Error in chol.default(Bmat) : the leading minor of…
0
votes
0 answers

Trying to return from co generator runner in nodejs

I want to create a function that runs asynchronous code sequentialy. This function takes parameters and returns a Promise that resolves with a JavaScript object. It uses the co npm package in conjuction with generators to "pause" asynchronous code…
Kostas Letros
  • 53
  • 1
  • 11
0
votes
0 answers

Dataframe subsetting on a variable with the same value

I have a simple data frame like this: col1 col2 a 1 b 2 a 2 I'll refer to this data frame as table. I am trying to create variables a1 and a2 where the value of a1 would be 1 in this instance and the value of a2 would be 2.…
0
votes
0 answers

How do you delete an element from an array in C++?

I'm trying to make a program of choosing numbers and deleting arrays after. How do I delete an element of an array in a code? #include #include using namespace std; void main() { int array[4]; array[0] = 1; …
user12548653
0
votes
1 answer

What causes the SVN error "Revision xxx doesn't match existing revision yyy..."

I'm using a recent version of SVN to check out some files (using 'svn co URL DEST'). When I do this, I get an error that says "svn: E155000: Revision 11134260 doesn't match existing revision 11075284 in DEST". However, if I use a 2011 version…
Brett
  • 11
  • 5
0
votes
1 answer

I have a co routine that once selected plays through. However If i go to select it again nothing happens. It does work the first time however

I have a co routine that once selected plays through. The co routine scales an object up. The second one it's selected it scales down the object. However If i go to select it again nothing happens. It does work the first time however. using…
jono
  • 35
  • 8