text: // Promisify synchronous function
  
  'use strict';
  
  var callable         = require('es5-ext/object/valid-callable')
    , deferred         = require('../../deferred')
    , isPromise        = require('../../is-promise')
    , processArguments = require('../_process-arguments')
  
    , apply = Function.prototype.apply
  
    , applyFn;
  
  applyFn = function (fn, args, resolve, reject) {
  	var value;
  	try {
  		value = apply.call(fn, this, args);
  	} catch (e) {
  		reject(e);
  		return;
  	}
  	resolve(value);
  };
  
  module.exports = function (length) {
  	var fn, result;
  	fn = callable(this);
  	if (fn.returnsPromise) return fn;
  	if (length != null) length = length >>> 0;
  	result = function () {
  		var args, def;
  		args = processArguments(arguments, length);
  
  		if (isPromise(args)) {
  			if (args.failed) return args;
  			def = deferred();
  			args.done(function (args) {
  				applyFn.call(this, fn, args, def.resolve, def.reject);
  			}.bind(this), def.reject);
  		} else {
  			def = deferred();
  			applyFn.call(this, fn, args, def.resolve, def.reject);
  		}
  
  		return def.promise;
  	};
  	result.returnsPromise = true;
  	return result;
  };
  