madmurphy / stringview.js Goto Github PK
View Code? Open in Web Editor NEWC-like string interface for JavaScript
License: GNU Lesser General Public License v3.0
C-like string interface for JavaScript
License: GNU Lesser General Public License v3.0
Link to this page: https://developer.mozilla.org/en-US/Add-ons/Code_snippets/StringView
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Code_snippets/StringView
Maybe the page has been removed on the MDN.
Can you implement an efficient toString() function, whose time complecity is O(L), (L is the length of the final string). Direct concatation using '+' has O(L^2) time complexity.
cc = "Hello world!".split("").map(function(char) { return char.charCodeAt(0); });
var buf = new Uint8Array(cc);
var myStringView1 = new StringView(buf, 'UTF-8', 1);
console.log(myStringView1.subview(3, 7).toString()); // "lo worl", expected: "o world"
var myStringView2 = new StringView(buf, 'UTF-8', 2, 5);
console.log(myStringView2.subview(3, 7).toString()); // "lo", expected: " w"
var myStringView3 = new StringView(buf, 'UTF-8', 0, 3);
console.log(myStringView3.subview(3, 7).toString()); // "Hel", expected: ""
var myStringView4 = new StringView(buf, 'UTF-8', 0, 5);
console.log(myStringView4.subview(1).toString()); // RangeError, expected: "ello"
Any chance we can get an MIT license? I'd like to port this to dart.
In the js file it says the license is LGPL3 but the LICENSE file says it is GPL3. Which is the correct one? I'm guessing the one in the JS file, as found on the Mozilla site.
If I'm not wrong utf8 char codes span 4 bytes at most. Is there any reason to check for 6 bytes?
https://github.com/madmurphy/stringview.js/blob/master/stringview.js#L325
The same applies to putUTF8CharCode
https://github.com/madmurphy/stringview.js/blob/master/stringview.js#L341
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.