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

ts-core-lib

v1.0.1

Published

Library that enhance the development experience when working with TypeScript projects.

Downloads

5

Readme

TypeScript Core Lib

TypeScript Core Lib (tsclib) is a versatile library designed to enhance the development experience when working with TypeScript projects. This comprehensive library offers essential functionalities that go beyond the standard ECMAScript, providing developers with a robust set of tools. From streamlined methods for rounding numbers to managing sealed arrays and maps, tsclib covers a wide array of utilities. Additionally, it introduces LINQ-like features and an array of other functions, filling the gaps in ECMAScript standardization.

Installation

# Install with npm
npm install ts-core-lib
# Install with yarn
yarn add ts-core-lib

NPM scripts

Compile the TypeScript code using both the tsconfig.json and tsconfig.module.json files.

npm run build

Runs the unit tests using AVA.

npm run test

Watches for changes in the TypeScript code and recompiles the code using tsconfig.json.

npm run watch:build

Watches for changes in the TypeScript code and re-runs the unit tests using AVA.

npm run watch:test

Generates an HTML report of the code coverage using NYC and opens the report in the browser.

npm run cov

Generates HTML documentation of the TypeScript code and opens the documentation in the browser.

npm run doc

Contribution & Issues

If you do encounter any problems, please file an issue or submit a PR. Everyone is welcome and encouraged to contribute.

If submitting a request to add a new module/functionality, please ensure you add the appropriate tests covering your module. In the interests of stability, PRs without tests cannot be considered.

Folder Structure

  • src: The source code of the library is organized under this directory.
    • <module>: Each module of the library is contained in its own subdirectory. It includes:
      • index.ts: This file serves as the main entry point for the module and exports all other files within the module.
    • tests: This directory contains test files for the module.
    • ovw: This directory contains overrides for built-in TypeScript types that need to be extended or modified see example below.
    • index.ts: The root source file and lib entry point. All modules are exported from this file.

Example module

Let's take an example of a module named example

// src/example/index.ts
export * from './MyClass.ts';
// src/example/MyClass.ts

// Best way is to import the hole lib itself
import { isInt, NotAnIntegerError } from '../index';

export class MyClass {
    /**
     * Returns the sum of a and b.
     *
     * @param a - The left node.
     * @param b - The right node.
     * @throws {NotAnIntegerError} Throws an error if either a or b is not an integer.
     * @returns The sum of a and b.
     */
    public static sum(a: number, b: number): number {
        if (!isInt(a)) {
            throw new NotAnIntegerError(a);
        }
        if (!isInt(b)) {
            throw new NotAnIntegerError(b);
        }
        return a + b;
    }
}
// src/tests/example.spec.ts
import test from 'ava';
import { MyClass } from '../index';


test("MyClass.sum returns correct values", (t) => {
    t.assert(MyClass.sum(1, 2) == 3);
});

If you want that your module is loaded automatically add the following line:

// src/index.ts
export * from "./example";

Make sure to document your code so that TypeDoc can extract them and generate a documentation out of it.

Building and Testing

Make sure to run tests and build the project before contributing. Use the following commands:

# Run tests
npm test

# Run coverage
npm run cov

# Build the project
npm run build

Thanks

Thanks to all those who have contributed to the further development of this library.