Skip to content
"description": "Copy a descriptor from object A to object B",
Branch: master
Clone or download
Latest commit de88234 Jun 10, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples first commit Dec 28, 2015
.editorconfig first commit Dec 28, 2015
.eslintrc.json run update Jun 9, 2016
.gitattributes first commit Dec 28, 2015
.gitignore first commit Dec 28, 2015
.travis.yml first commit Dec 28, 2015 generate readme with verb Dec 28, 2015
LICENSE run update Jun 9, 2016
index.js allow function values Jun 9, 2016
package.json 0.1.1 Jun 9, 2016 run update Jun 9, 2016
test.js add unit tests Dec 28, 2015

copy-descriptor NPM version NPM downloads Build Status

Copy a descriptor from object A to object B


Install with npm:

$ npm install copy-descriptor --save


var copy = require('copy-descriptor');



Copy a descriptor from one object to another.


  • receiver {Object}: The target object
  • provider {Object}: The provider object
  • from {String}: The key to copy on provider.
  • to {String}: Optionally specify a new key name to use.
  • returns {Object}


function App() {
  this.cache = {};
App.prototype.set = function(key, val) {
  this.cache[key] = val;
  return this;
Object.defineProperty(App.prototype, 'count', {
  get: function() {
    return Object.keys(this.cache).length;

copy(App.prototype, 'count', 'len');

// create an instance
var app = new App();

app.set('a', true);
app.set('b', true);
app.set('c', true);

//=> 3
//=> 3

Related projects

You might also be interested in these projects:


This document was generated by verb-readme-generator (a verb generator), please don't edit directly. Any changes to the readme must be made in See Building Docs.

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Or visit the verb-readme-generator project to submit bug reports or pull requests for the readme layout template.

Building docs

Generate readme and API documentation with verb:

$ npm install -g verb verb-readme-generator && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test


Jon Schlinkert


Copyright © 2016, Jon Schlinkert. Released under the MIT license.

This file was generated by verb, v0.9.0, on June 09, 2016.

You can’t perform that action at this time.