Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependendency on Node.js #18

Closed
photopea opened this issue Jun 28, 2017 · 6 comments
Closed

Remove dependendency on Node.js #18

photopea opened this issue Jun 28, 2017 · 6 comments

Comments

@photopea
Copy link

photopea commented Jun 28, 2017

Whould it be possible to remove the Node.js - specific code? I think such library can be made with simple strings, arrays, numbers, there is no need to have I/O etc. inside it. I would like to use a similar tool in the browser environment.

You use many third-party libraries. I am sure that writing your own functions could improve the performance. These libraries are often stupid-proof (e.g. every time they check, if the input parameter is a string, or a number, or undefined ....) which ruins the performance.

@jameslawson
Copy link
Contributor

This library is designed for use in a browser environment. The only Javascript that targets a Node.js environment should be code for running tests (code inside /test/ directory). Can you please be more specific about which lines of code are causing errors in a browser environment?

More work is needed for performance. There is an open issue #12 where you can contribute.

@photopea
Copy link
Author

There is this code like import includes from 'lodash.includes';

I just googled, that "import" is not a command for Node.js, but it is a new specification of JS. But it is not supported by browsers yet, so I will probably see an error in my browser.

@jameslawson
Copy link
Contributor

jameslawson commented Jun 29, 2017

@photopea The example I provided assumed the use of a transpiler like babel together with a module bundler like webpack. These are modern build tools used to convert (compile) ES6 to ES5 so that the code works in older browsers. Sorry, there was not much explanation about this.

I've now updated the README and given examples of how to get started.
You have four options:

  1. ES6 with import – requires a transpiler + bundler (e.g. babel, webpack)
  2. CommonJs – requires a bundler (e.g. webpack)
  3. RequireJs – works straight away in browser - no build tools needed
  4. <script> tag – works straight away in browser - no build tools needed

All of the above four options can be used to get unicode-bidirectional to work in a browser environment.

@photopea
Copy link
Author

Thank you very much. I don't use any additional software for JS development. Can you add the JS file, that works in a browser, to your repository?

@jameslawson
Copy link
Contributor

You can find the JS file that works in a browser (unicode.bidirectional.js) here: https://github.com/bbc/unicode-bidirectional/releases

Here is an example of how to use it:
https://github.com/bbc/unicode-bidirectional/blob/master/example/example4.html
You'll need to modify the value of the src attribute of the <script> tag to point the url where you have put unicode.bidirectional.js on your server.

I think that should sort your problem so I'm closing this issue.

@photopea
Copy link
Author

photopea commented Jul 3, 2017

Ok, thanks, it works very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants