npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@monadica/lazy-streams

v1.1.3

Published

Lazy data stream processing in TypeScript.

Downloads

879

Readme

LazyStreams

Welcome to @monadica/lazy-streams, an elegant and modular TypeScript library. Developed by Monadica.


Table of Contents


Features

  • TypeScript: Type-safe development with easy compilation to various JavaScript module formats.
  • ESM, CommonJS, UMD, and AMD Support: Out-of-the-box multi-module format support for broad compatibility.
  • Testing with Jest: Write robust unit tests with Jest.
  • Linting and Formatting: Ensure code consistency with ESLint and Prettier.
  • Automatic Documentation: Generate documentation from TSDoc comments with TypeDoc.
  • Automated Semantic Versioning: Manage versioning with standard-version for seamless releases.

Installation

To install the latest version of @monadica/lazy-streams from npm, use the following command:

npm install @monadica/lazy-streams

Getting Started

To use or modify this library, follow these steps:

  1. Clone the Repository

Clone this repository to your local machine and navigate to the project directory.

git clone https://github.com/monadicarts/lazy-streams.git
cd lazy-streams
  1. Install Dependencies

Install the required dependencies using npm or yarn.

npm install
  1. Start Coding

You’re now ready to start building your own TypeScript npm package!

Project Structure

lazy-streams/
├── CHANGELOG.md              # Automatically generated changelog for tracking
|                             #   version history and changes
├── LICENSE                   # License file, typically contains the MIT
|                             #   license or other open-source license terms
├── README.md                 # Main documentation file for the project, with
|                             #   setup, usage instructions, and more
├── docs                      # Directory containing generated documentation
|                             #   files from TypeDoc
|   ├── assets                # Assets for the documentation, such as CSS,
|   |                         #   icons, and JavaScript files for styling and
|   |                         #   functionality
|   |   ├── highlight.css     # CSS file for syntax highlighting in code
|   |   |                     #   samples within the documentation
|   |   ├── icons.js          # JavaScript file for managing icons in the
|   |   |                     #   documentation
|   |   ├── icons.svg         # SVG file containing icon definitions
|   |   ├── main.js           # Main JavaScript file for documentation page
|   |   |                     #   interactivity
|   |   ├── navigation.js     # JavaScript file for handling navigation in the
|   |   |                     #   documentation
|   |   ├── search.js         # JavaScript file for implementing search
|   |   |                     #   functionality within the documentation
|   |   └── style.css         # General styling for the documentation pages
|   ├── classes               # Documentation pages for each class defined in
|   |   |                     #   the project
|   |   └── LazyStream.html   # HTML documentation page for the LazyStream
|   |                         #   class
|   ├── index.html            # Main entry point for the generated
|   |                         #   documentation
|   └── modules.html          # Documentation index for modules in the project
├── eslint.config.cjs         # ESLint configuration file in CommonJS format
|                             #   for linting the codebase
├── jest.config.cjs           # Jest configuration file in CommonJS format for
|                             #   setting up the testing environment
├── package-lock.json         # Automatically generated lock file for managing
|                             #   exact dependency versions
├── package.json              # Main package configuration file with metadata,
|                             #   dependencies, and scripts
├── rollup.config.js          # Rollup configuration file for bundling the
|                             #   project into different module formats
├── src                       # Directory containing the source code and tests
|   ├── LazyStream.ts         # Main implementation file for the LazyStream
|   |                         #   class
|   ├── __tests__             # Directory for unit tests
|   |   └── LazyStream.spec.ts# Unit test file for the LazyStream class
|   └── index.ts              # Entry point of the module, exports main classes
|                             #   and functions
├── tsconfig.json             # TypeScript configuration file with compiler
|                             #   options
└── typedoc.json              # TypeDoc configuration file for generating
                              #   documentation based on TSDoc comments

Usage

Here’s a short example of how to use the @monadica/lazy-streams library to create a lazy stream, apply transformations, and retrieve results:

import { LazyStream } from "@monadica/lazy-streams";

// Create a lazy stream from an array
const stream = LazyStream.from([1, 2, 3, 4, 5]);

// Apply transformations: multiply each element by 2 and filter even results
const transformedStream = stream.map((x) => x * 2).filter((x) => x % 2 === 0);

// Take the first 3 elements of the transformed stream and convert to array
const result = transformedStream.take(3).toArray();

console.log(result); // Output: [2, 4, 6]

This example demonstrates:

  • Creating a lazy stream from an array
  • Using map to transform values
  • Using filter to filter out certain values
  • Using take to limit the results
  • Converting the final stream to an array using toArray

Scripts

A set of npm scripts are preconfigured to streamline development and publishing:

  • npm run build: Compiles TypeScript to JavaScript in multiple module formats (ESM, CommonJS, UMD, AMD).
  • npm test: Runs Jest tests.
  • npm run lint: Checks code for linting errors using ESLint.
  • npm run format: Formats code with Prettier.
  • npm run docs: Generates documentation with TypeDoc.
  • npm run release: Bumps version and updates changelog based on commit messages using standard-version.
  • npm publish: Publishes the package to npm (run after npm run release).

Configuration

This template includes configuration files for various tools, such as:

  • TypeScript (tsconfig.json): Configures compiler options and output.
  • ESLint (eslint.config.cjs): Configures linting rules for code consistency.
  • Prettier (.prettierrc): Configures formatting rules for consistent style.
  • Jest (jest.config.cjs): Configures Jest for unit testing.
  • TypeDoc (typedoc.json): Configures TypeDoc for documentation generation.

Contributing

We welcome contributions! To contribute:

  1. Fork the repository and create a new branch (git checkout -b feature/YourFeature).
  2. Make your changes and commit them (git commit -m "Add feature").
  3. Push to the branch (git push origin feature/YourFeature).
  4. Open a Pull Request.

If you have any questions or suggestions, please reach out to us at [email protected].

License

This project is licensed under the MIT License.

Developed and maintained by Monadica.

Thank you for using @monadica/lazy-streams!

Contact

Happy Coding! 🚀