Git Product home page Git Product logo

js-coroutines's People

Contributors

genderev avatar miketalbot avatar null-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-coroutines's Issues

Simple examples?

Would love some simple examples for the various api methods. Was trying to implement just a simple reduceAsync but couldn't get it working. The accumulator was always not what i defined it as (as the 3rd argument) and instead was always the first item in the array. Maybe I'm doing something wrong, hard to know without some examples though :)

Edit: I do see a reduce in the demo, however that seemed like a more advanced use case in the context it was used? Anyway, a simple stand alone reduceAsync example would be appreciated!

parseAsync does not handle exponential floating point numbers

Describe the bug
parseAsync throws error when json contains exponential number

To Reproduce

const a = JSON.parse('{"dx": 8.97569134394871e-06}')
     console.log(a)
     let item = await parseAsync('{"dx": 8.97569134394871e-06}')
// throws exception:     Error: state INIT, unexpected token e
     console.log(item)

Expected behavior
Should be able to parse exponential number
{ dx: 0.00000897569134394871 }

Additional context
Run using Node 14.9

Nodejs memory error

Hello

I experience an issue on Nodejs 15.3.0 ( but also on prior version ) express server,

after requiring js-coroutines e.g:
...
const mapAsync = require('js-coroutines').mapAsync
...

server crashes after starting in a few minutes.

After not referencing js-coroutines everything goes ok even if I do not uninstall the package.

I would really like to use the library in production. on server as well.

On client side (JS) is working as expected.

thank you,


<--- Last few GCs --->

[23344:00000263D8DCE310] 369156 ms: Mark-sweep 4045.0 (4135.1) -> 4033.4 (4136.9) MB, 3324.5 / 0.1 ms (average mu = 0.129, current mu = 0.029) task scavenge might not succeed
[23344:00000263D8DCE310] 373604 ms: Mark-sweep 4046.0 (4136.9) -> 4034.7 (4138.4) MB, 4341.8 / 0.0 ms (average mu = 0.072, current mu = 0.024) task scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF6751B33EF v8::internal::Isolate::ArchiveSpacePerThread+4447
2: 00007FF67514DEA6 v8::internal::MicrotaskQueue::GetMicrotasksScopeDepth+65030
3: 00007FF67514EDA6 node::OnFatalError+294
4: 00007FF675A49FEE v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF675A2E6FD v8::SharedArrayBuffer::Externalize+781
6: 00007FF6758C814C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
7: 00007FF6758D3831 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1281
8: 00007FF6758D07F9 v8::internal::Heap::PageFlagsAreConsistent+2377
9: 00007FF6758C5371 v8::internal::Heap::CollectGarbage+1969
10: 00007FF675874A67 v8::internal::ItemParallelJob::Item::TryMarkingAsProcessing+3079
11: 00007FF6750E00AF v8::CFunction::ReturnInfo+17023
12: 00007FF6750DE8D6 v8::CFunction::ReturnInfo+10918
13: 00007FF67520BAEB uv_async_send+331
14: 00007FF67520B27C uv_loop_init+1292
15: 00007FF67520B41A uv_run+202
16: 00007FF6751DAC94 node::SpinEventLoop+308
17: 00007FF675108E07 EVP_CIPHER_CTX_buf_noconst+52551
18: 00007FF67517CF8B node::Start+283
19: 00007FF674FB7BEC RC4_options+344812
20: 00007FF675FD1C3C v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+153276
21: 00007FF946C77C24 BaseThreadInitThunk+20
22: 00007FF947BCD4D1 RtlUserThreadStart+33

stringifyAsync includes keys with value `undefined', which is different from JSON.stringify

Describe the bug

When stringifying an object using stringifyAsync, there is a different hanlding of undefined values than with JSON.stringify

To Reproduce

const object = {
    'foo': 'foo',
    'bar': undefined
}
const strAsync = (await stringifyAsync(object)).toString()
// result: {"foo":"foo","bar":null}
const str = JSON.stringify(object)
// result: {"foo":"foo"}

Note that the undefined value bar does not exist in the output of JSON.stringify, while it is null in the output of stringifyAsync.

Expected behavior

Since the documentation of stringifyAsync does not list any specific behaviour, I would have expected it to have the same behaviour as JSON.stringify and to not include keys with value undefined in the serialized string.

Environments

Tested on node 18.15.0 on Linux and Chrome 112.0.5615.138 on Windows

Compose

I know is not a big issue as long as "pipe" is available, but perhaps a "compose" like function will be welcomed as well;

performance.now is not a function

TypeError: performance.now is not a function
    at Timeout.runFromTimeout [as _onTimeout] (/Users/devonte/Documents/GetCircuit/circuit-api/node_modules/js-coroutines/dist/coroutines.js:191:31)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

Can I just use it in my browser without Nodejs?

Sorry I may totally miss the objective of the project, but can I just use it in my browser?

Say I have to log to console something every 16 ms, while sorting a massive array. How do I do it?

To have a real quick start, I don't even want to learn React.

Actually does js-coroutines require React?

parseAsync failing with valid whitespace

Super interested in this library! But I am getting a failure on my first attempts at using parseAsync; maybe I am doing something stupid?

The following seemingly valid simple code fails:

const mytext = '{"type": "FeatureCollection", "features": [1,2,3]}'
const json = await parseAsync(mytext)
console.log(json)

with the error message

Uncaught (in promise) Error: Unexpected character [n:32] ':' @ 8 - {"type": "FeatureCollect
(tokenizer.js:360)

Now if I remove the whitespace from the json string, it works:

const mytext = '{"type":"FeatureCollection","features":[1,2,3]}'
const json = await parseAsync(mytext)
console.log(json)

Success!

Object { type: "FeatureCollection", features: (3) […] }

The JSON string I'm receiving is coming from another tool, so I cannot manually remove the whitespace to make this work; nor should I have to, should I?

Let me know if I can provide further info. Happy to help debug what I'm doing wrong.

stringifyAsync does not properly escape embedded empty strings

Input Object:
{name:"person",extra_info:'{country:"",age:35}'}
This line is output by stringifyAsync (notice the missing escape on 2nd quote on country member):
{"name":"person","extra_info":"\"country\":\"",\"age\":35"}
This is the correct line output by JSON.stringify:
{"name":"person","extra_info":"\"country\":\"\",\"age\":35"}

Can it be used to improve scroll animation?

I have a rather laggy scroll animation because too many calculation happens inside each tick. Of course the best option is to improve the calculation, but assuming that it cannot be done then will this library help?

Thank you and congrats on the lib.

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.