Điểm qua winterbe/streamjs: 855 sao trên GitHub, viết chủ yếu bằng JavaScript, thuộc nhóm Frontend. Lazy Object Streaming Pipeline for JavaScript
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
ATTENTION: Stream.js is no longer maintained in favor of it's successor library Sequency. If you already use Stream.js in your project I recommend switching to Sequency. But don't worry, Stream.js still works fine so no hurry. 😉
Lazy Object Streaming Pipeline for JavaScript - inspired by the Java 8 Streams API
Stream.js is a lightweight (2.6 KB minified, gzipped), intensely tested (700+ assertions, 97% coverage) functional programming library for operating upon collections of in-memory data. It requires EcmaScript 5+, has built-in support for ES6 features and works in all current browsers, Node.js and Java 8 Nashorn.
Download the latest release from GitHub or install Stream.js via NPM or Bower:
npm install streamjs
# or
bower install streamjs
Read the APIDOC
Examples
Before explaining how Stream.js works in detail, here's a few real world code samples.
Filter and sort a collection of persons, then group everything by age.
Filter and transform a collection of tweets to its text content, then limit the tweets to a maximum of 100 and partition the results into 10 tweets per page:
Streams are monadic types with a bunch of useful operations. Those functions can be chained one after another to make complex computations upon the input elements. Operations are either intermediate or terminal. Intermediate operations are lazy and return the stream itself to enable method chaining. Terminal operations return a single result (or nothing at all). Some terminal operations return a special monadic Optional type which is described later.
Streams are not limited to finite data sources like collections. You can also create infinite streams of elements by utilizing generator or iterator functions.
Stream.iterate(1, function (seed) {
return seed * 2;
});
Why Stream.js?
What's so different between Stream.js and other functional libraries like Underscore.js?
Stream.js is built around a lazily evaluated operation pipeline. Instead of consecutively performing each operation on the whole input collection, objects are passed vertically and one by one upon the chain. Interim results will not be stored in internal collections (except for some stateful operations like sorted). Instead objects are directly piped into the resulting object as specified by the terminal operation. This results in minimized memory consumption and internal state.
Stream operations are lazily evaluated to avoid examining all of the input data when it's not necessary. Streams always perform the minimal amount of operations to gain results. E.g. in a filter - map - findFirst stream you don't have to filter and map the whole data. Instead map and findFirst are executed just one time before returning the single result. This results in increased performance when operation upon large amounts of input elements.
Stream([1, 2, 3, 4])
.filter(function(num) { // called twice
return num % 2 === 0;
})
.map(function(even) { // called once
return "even" + even;
})
.findFirst(); // called once
API Documentation
The Stream.js API is described in detail here. For more information about Java 8 Streams I recommend reading the official Javadoc and this blog post.
A type definition for using Stream.js with Typescript is available here.
Contributing
Found a bug or missing feature? Please open an issue! Your feedback and help is highly appreciated. Please refer to the contributing rules before sending a pull request. I would also love to hear your feedback via Twitter.
Copyright and license
Created and copyright (c) 2014-2016 by Benjamin Winterberg.
Stream.js may be freely distributed under the MIT license.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/winterbe/streamjs là nguồn chính thức.
winterbe/streamjs có bao nhiêu sao?
winterbe/streamjs có 855 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/winterbe/streamjs. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
winterbe/streamjs có phải mã nguồn mở không?
Có — winterbe/streamjs phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/winterbe/streamjs.
winterbe/streamjs còn đang phát triển không?
Commit gần nhất trên winterbe/streamjs là 9.2 năm trước (theo timestamp GitHub). Repo có 65 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
winterbe/streamjs là gì?
winterbe/streamjs (winterbe/streamjs) là dự án JavaScript trên GitHub. Theo mô tả gốc: Lazy Object Streaming Pipeline for JavaScript
winterbe/streamjs so với các dự án Frontend khác thế nào?
winterbe/streamjs được TopGit xếp vào nhóm Frontend, với 855 sao GitHub và viết bằng JavaScript. Xem trang chủ đề Frontend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
streamjs có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về streamjs.