Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 672 Bytes

README.md

File metadata and controls

36 lines (25 loc) · 672 Bytes

method-call

This library allows you to use _ style method calls like in Scala.

Usage

import _ from 'method-call'

const names = ['fabien', 'donny', 'dave'];

const NAMES = names.map(_.toUpperCase); // ['FABIEN', 'DONNY', 'DAVE'];
import _ from 'method-call'
import Model from 'some-mvc'

class Document extends Model{
    constructor(id){
        this.id = id;
        super(id);
    }

    save(){
        const url = '/documents/' + this.id;
        return this.sync.post(url, this.attributes);
    }

}

let docs = [new Document(1), new Document(20)];

docs.forEach(_.save); // equiv to docs.forEach(d => d.save);