]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/curry.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / node_modules / es5-ext / function / # / curry.js
1 'use strict';
2
3 var toPosInt     = require('../../number/to-pos-integer')
4   , callable     = require('../../object/valid-callable')
5   , defineLength = require('../_define-length')
6
7   , slice = Array.prototype.slice, apply = Function.prototype.apply
8   , curry;
9
10 curry = function self(fn, length, preArgs) {
11         return defineLength(function () {
12                 var args = preArgs ?
13                                 preArgs.concat(slice.call(arguments, 0, length - preArgs.length)) :
14                                 slice.call(arguments, 0, length);
15                 return (args.length === length) ? apply.call(fn, this, args) :
16                                 self(fn, length, args);
17         }, preArgs ? (length - preArgs.length) : length);
18 };
19
20 module.exports = function (/*length*/) {
21         var length = arguments[0];
22         return curry(callable(this),
23                 isNaN(length) ? toPosInt(this.length) : toPosInt(length));
24 };