New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

typescript-functors

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-functors

A very small library to transform ordinary objects to Functors

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

typescript-functors

This is a very small libary for transforming objects into functors

Installation:

    npm install --save typescript-functors

Usage

import {Functor} from 'typescript-functors';
...

//To transform any object to a functor, just wrap it using Functor.of() and retrieve data using .get()

let obj = {...};
let functorObj = Functor.of(obj).get();

//You can map Arrays as usual
let arr: Array = [1,2,3];
let mapped: Array = Functor.of(arr).map(num=>num*2).get();
console.log(mapped); //[2,4,6]

//You can map Objects as well
let person = {
    name: "Cersei",
    family: "Lannister"
};

let name = Functor.of(person).map(obj=>obj.name).get();
console.log(name);// Cersei

//Or Arrays of Objects
let starks = [
    {
        name: "Eddard",
        status: "Dead"
    },
    {
        name: "Catelyn",
        status: "Dead"
    },
    {
        name: "Arya",
        status: "Alive"
    }
];
let names = Functor.of(starks).map(stark=>stark.name).get();
console.log(names);//["Eddard","Catelyn","Arya"]

Keywords

Functor

FAQs

Package last updated on 06 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts