Skip to content

micro-js/set-proto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

set-proto

Build status Git tag NPM version Code style

Set the proto of an object.

Installation

$ npm install @f/set-proto

Usage

var setProto = require('@f/set-proto')

var man = {talk: () => 'hello'}
var cat = {talk: () => 'meow'}
var obj = {}

setProto(man, obj)
obj.talk() // => 'hello'
setProto(cat, obj)
obj.talk() // => 'meow'

API

setProto(proto, obj)

  • proto - The object's new prototype.
  • obj - The object which is to have its prototype set.

Returns: obj

License

MIT