Git Product home page Git Product logo

buffer-browserify's People

Contributors

andreasmadsen avatar andrewrk avatar fanatid avatar feross avatar hegemonic avatar justintulloss avatar mscdex avatar mwilliamson avatar rdrey avatar sokra avatar stepek avatar tonistiigi avatar toots avatar ysangkok 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

Watchers

 avatar  avatar  avatar  avatar

buffer-browserify's Issues

ciruclar dependency buffer and assert

I am getting an empty assert object, and seems to be related to a circular dependency between buffer and assert. anybody else experiencing this problem?

Buffer.isBuffer returns false for Buffers

I ran into this while writing a browser side Writable Stream.
The problem is basically that Buffer.isBuffer(buf) returns false although it is one. This is due to buf instanceof Buffer returning false -- I tried this in the browser console as well.

I commented on my workaround here.

You could use this project as a test bed, i.e.:

npm install d3-gauge-writable
npm explore d3-gauge-writable
npm start

You should then be able to debug into d3-gauge-writable assuming you enabled source maps on your browser.

node.js simple tests

I tried to run this module with the Buffer tests from node
( https://github.com/joyent/node/blob/master/test/simple/test-buffer.js )

Tests run in Chrome 19.0.1084.52 m. May not all tests can be fixed...

I tried to omit duplicate errors.

This are the results:

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L33

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L48

TypeError: Object #<error> has no method 'copy'
    at Buffer.copy (buffer-browserify/index.js:598:22)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L186

AssertionError: "hello world" == "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"

writing and reading via buffer[number] does not work. This causes that error. (and that in L207)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L250

Error: Unknown encoding
    at Function.byteLength (buffer-browserify/index.js:58:13)
    at new Buffer (buffer-browserify/index.js:323:30)

Encodings: 'ucs2', 'utf-16le', 'binary'

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L320

the base64 decoder should ignores whitespace and illegal chars.

Invalid string. Length must be a multiple of 4

https://github.com/beatgammit/base64-js/blob/master/lib/b64.js#L10 should throw an Error not a string!

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L343

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L379 and more

Invalid string. Length must be a multiple of 4

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L432

TypeError: Object #<error> has no method 'binarySlice'
    at Buffer.toString (buffer-browserify/index.js:512:26)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L569

TypeError: Object #<error> has no method 'fill'
    at Buffer.fill (buffer-browserify/index.js:558:22)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L605

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L623

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L706

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L719

buf[i] not working sometimes

Causing zlib-browserify to be broken: brianloveswords/zlib-browserify#6

To produce the issue:

  1. Clone this gist
  2. browserify test.js >out.js
  3. Copy out.js into jsbeautifier.org and then paste back into out.js
  4. Add a debugger statement like this:
                        debugger
                        a.C = l[k++];
                        a.D = l[k++];
                        (31 !== a.C || 139 !== a.D) && m(Error("invalid file signature:", a.C, a.D));
  1. run in the browser

You will notice that l is a Buffer and l[0] is yielding undefined when it should yield 31. Note also that l.parent[0] works.

Wrong behavior with base64

hi!

there is a strange behavior when invoking the following:

var b = new Buffer('APw', 'base64');
var r = [];
for (var i = 0; i < b.length;) {
    // Calculate charcode from two adjacent bytes.
    r.push(String.fromCharCode(b[i++] << 8 | b[i++]));
}
return r.join('');

on node, this returns 'ΓΌ', but in your implementation, it fails with the message:
"Invalid string. Length must be a multiple of 4", caused by require("base64-js").toByteArray ...

Is there a way around this, e.g. using the native base64 to ascii implemenations?

cheers
felix

Problem with write{Uint,Int}{16,32}{LE,BE}, not writing in right array

test("hex of int16 3", function(t) {
    t.plan(1);
    var v1=new buffer.Buffer(2);
    var v2=new Buffer(2);
    v1.writeInt16BE(3,0);
    v2.writeInt16BE(3,0);
    t.equal(
            v1.toString("hex"),
            v2.toString("hex")
    );
    t.end();
});

This test fails. But if I change the assignments in writeUInt16 to:

if (isBigEndian) {
  buffer.parent[buffer.offset+offset] = (value & 0xff00) >>> 8;
  buffer.parent[buffer.offset+offset + 1] = value & 0x00ff;
} else {
  buffer.parent[buffer.offset+offset + 1] = (value & 0xff00) >>> 8;
  buffer.parent[buffer.offset+offset] = value & 0x00ff;
}

It seems to work. But is it this simple? Seems like the parent is not always used.

slicing support

Hi!

I need slicing for a library that i am porting.

I have started to look into how to make it work. The main issue seems to me that Buffer.slice and Array.slice work in a different way. The first references to the original buffer, and modifications alter the original buffer, while the second generates a new copy.

Did you started to look into this? comments / directions are welcome!

Tests fail on OS X, Node v0.10.22

Any ideas?

    ok 979 should be equal
    ok 980 should be equal
    ok 981 should be equal
    ok 982 should be equal
    ok 983 should be equal
    ok 984 should be equal
    ok 985 should be equal
    ok 986 should be equal
    ok 987 should be equal
    not ok 988 test/buffer.js
      ---
        exit:     143
        timedOut: true
        stderr:   |
          (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
          Trace
              at EventEmitter.addListener (events.js:160:15)
              at test (/Users/feross/code/buffer-browserify/node_modules/tape/index.js:103:11)
              at Object.<anonymous> (/Users/feross/code/buffer-browserify/test/buffer.js:104:1)
              at Module._compile (module.js:456:26)
              at Object.Module._extensions..js (module.js:474:10)
              at Module.load (module.js:356:32)
              at Function.Module._load (module.js:312:12)
              at Function.Module.runMain (module.js:497:10)
              at startup (node.js:119:16)
              at node.js:901:3
          (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
          Trace
              at EventEmitter.addListener (events.js:160:15)
              at test (/Users/feross/code/buffer-browserify/node_modules/tape/index.js:108:11)
              at Object.<anonymous> (/Users/feross/code/buffer-browserify/test/buffer.js:104:1)
              at Module._compile (module.js:456:26)
              at Object.Module._extensions..js (module.js:474:10)
              at Module.load (module.js:356:32)
              at Function.Module._load (module.js:312:12)
              at Function.Module.runMain (module.js:497:10)
              at startup (node.js:119:16)
              at node.js:901:3
          (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
          Trace
              at EventEmitter.addListener (events.js:160:15)
              at test (/Users/feross/code/buffer-browserify/node_modules/tape/index.js:110:11)
              at Object.<anonymous> (/Users/feross/code/buffer-browserify/test/buffer.js:104:1)
              at Module._compile (module.js:456:26)
              at Object.Module._extensions..js (module.js:474:10)
              at Module.load (module.js:356:32)
              at Function.Module._load (module.js:312:12)
              at Function.Module.runMain (module.js:497:10)
              at startup (node.js:119:16)
              at node.js:901:3
        command:  "node" "buffer.js"
      ...

    1..988
    # tests 988
    # pass  987
    # fail  1

ok test/indexes.js .................................... 22/22
ok test/is-encoding.js .................................. 4/4
total ............................................. 1013/1014

not ok
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

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.