inexorabletash / text-encoding

Polyfill for the Encoding Living Standard's API
Other
722 stars 267 forks source link

Cant use: TextEncoder is not a constructor #76

Open Bizarrus opened 6 years ago

Bizarrus commented 6 years ago

By the sample (https://github.com/inexorabletash/text-encoding#api-overview) i try to use these module.

But i can't insert your module to run it.

const TextEncoder = require('text-encoding'); message = new TextEncoder("utf-8").encode(message);

Is it only a clientside module or a serverside module? No informations given. Bad docs.

paulkaplan commented 6 years ago

Try const TextEncoder = require('text-encoding').TextEncoder;

Bizarrus commented 6 years ago

Nope, it will create an Exception: ReferenceError: TextEncoder is not defined. Same with Decoder.

inexorabletash commented 6 years ago

I strongly regret ever adding npm/package/module support. This is a client-side polyfill, and more a reference implementation than anything intended for production use.

Fixes welcome that don't break the non-module approach.