@outsiderninjadevs/core
TypeScript icon, indicating that this package has built-in type declarations

17.0.1-rc1 • Public • Published

@outsiderninjadevs/core

@outsiderninjadevs/core is the Angular core library for the core utils. it has services that helps to build better angular apps with the most helpful functionalities.

@Outsiderninjadevs/core logo

Quality Gate Status

Features

  • Generate and download CSV files.

Installation

You can install @outsiderninjadevs/core via npm:

npm install @outsiderninjadevs/core

You also can explicitly give the version

npm install @outsiderninjadevs/core@17.0.1-rc1

Usage

  1. We strongly recommend using the new angular 17 standalone apps, that's why we have no more the OndCoreModule

  2. Create the list of elements

    // imports
    
    interface IUser {
        name: string;
        age: number;
        is_an_admin?: boolean;
    }
    
    @Component({
        // properties
    })
    export class MyComponent {
        usersList: IUser[] = [
            {
                name: 'Achraf',
                age: 24
            },
            {
                name: 'Alae',
                age: 18
            },
            // ...
        ];
    
    }
  3. We need to inject the OndCsvBuilderService in out component

    import {OndCsvBuilderService} from '@outsiderninjadevs/core';
    
    // imports
    
    @Component({
        // properties
    })
    export class MyComponent {
        
        constructor(
            private readonly csv: OndCsvBuilderService
        ) {}
    
    }
  4. We build the csv then we download.

    import {OndCsvBuilderService} from '@outsiderninjadevs/core';
    
    // imports
    
    interface IUser {
        name: string;
        age: number;
        is_an_admin?: boolean;
    }
    
    @Component({
        // properties
    })
    export class MyComponent {
        usersList: IUser[] = [
            {
                name: 'Achraf',
                age: 24
            },
            {
                name: 'Alae',
                age: 18
            },
            // ...
        ];
    
        constructor(
            private readonly csv: OndCsvBuilderService
        ) {}
    
        on_click(){
            // toCSVAsync and downloadCSVAsync are asynchronous functions
            csv.toCSVAsync<IUser>(usersList, ";") // the delimiter (;) is optional
                .then(async csvString => {
                    try{
                        await csv.downloadCSVAsync(csvString, "users.csv");
                    } catch (errorDown => {
                        alert("Error on download " + errorDown);
                    })
                }).catch(error => {
                    alert("Error " + error);
                });
        }
    }

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @outsiderninjadevs/core

Weekly Downloads

0

Version

17.0.1-rc1

License

MIT

Unpacked Size

73.3 kB

Total Files

12

Last publish

Collaborators

  • achrafmataich