src/back/models/methods.js
function concat(methodDictionary, func, name) {
  expect(arguments).to.have.length(
    3,
    'Invalid arguments length when concatenating a MethodDictionary (it has ' +
    'to be passed 3 arguments)'
  );

  expect(methodDictionary).to.be.instanceof(
    MethodDictionary,
    'Invalid argument "methodDictionary" when concatenating a ' +
    'MethodDictionary (it has to be a MethodDictionary)'
  );

  expect(func).to.be.a(
    'function',
    'Invalid argument "func" when concatenating a MethodDictionary ' +
    '(it has to be a function)'
  );

  expect(name).to.be.a(
    'string',
    'Invalid argument "name" when concatenating a MethodDictionary ' +
    '(it has to be a string)'
  );

  expect(methodDictionary).to.not.have.ownProperty(
    name,
    'Duplicated method name "' + name + '"'
  );

  var currentMethods = {};

  for (var currentMethod in methodDictionary) {
    currentMethods[currentMethod] = methodDictionary[currentMethod];
  }

  currentMethods[name] = func;

  return new MethodDictionary(currentMethods);
}
function concat(methodDictionary, func, name) {
  expect(arguments).to.have.length(
    3,
    'Invalid arguments length when concatenating a MethodDictionary (it has ' +
    'to be passed 3 arguments)'
  );

  expect(methodDictionary).to.be.instanceof(
    MethodDictionary,
    'Invalid argument "methodDictionary" when concatenating a ' +
    'MethodDictionary (it has to be a MethodDictionary)'
  );

  expect(func).to.be.a(
    'function',
    'Invalid argument "func" when concatenating a MethodDictionary ' +
    '(it has to be a function)'
  );

  expect(name).to.be.a(
    'string',
    'Invalid argument "name" when concatenating a MethodDictionary ' +
    '(it has to be a string)'
  );

  expect(methodDictionary).to.not.have.ownProperty(
    name,
    'Duplicated method name "' + name + '"'
  );

  var currentMethods = {};

  for (var currentMethod in methodDictionary) {
    currentMethods[currentMethod] = methodDictionary[currentMethod];
  }

  currentMethods[name] = func;

  return new MethodDictionary(currentMethods);
}
function concat ( methodDictionary , func , name ) { expect ( arguments ) . to . have . length ( 3 , 'Invalid arguments length when concatenating a MethodDictionary (it has ' + 'to be passed 3 arguments)' ) ; expect ( methodDictionary ) . to . be . instanceof ( MethodDictionary , 'Invalid argument "methodDictionary" when concatenating a ' + 'MethodDictionary (it has to be a MethodDictionary)' ) ; expect ( func ) . to . be . a ( 'function' , 'Invalid argument "func" when concatenating a MethodDictionary ' + '(it has to be a function)' ) ; expect ( name ) . to . be . a ( 'string' , 'Invalid argument "name" when concatenating a MethodDictionary ' + '(it has to be a string)' ) ; expect ( methodDictionary ) . to . not . have . ownProperty ( name , 'Duplicated method name "' + name + '"' ) ; var currentMethods = { } ; for ( var currentMethod in methodDictionary ) { currentMethods [ currentMethod ] = methodDictionary [ currentMethod ] ; } currentMethods [ name ] = func ; return new MethodDictionary ( currentMethods ) ; }
Concatenates a MethodDictionary instance with a new method and returns a new
MethodDictionary.
@name module:back4app-entity/models/methods.MethodDictionary.concat
@function
@param {!module:back4app-entity/models/methods.MethodDictionary}
methodDictionary The MethodDictionary to be concatenated.
@param {!function} func The method's function to be concatenated.
@param {!string} name The method's name to be concatenated.
@returns {module:back4app-entity/models/methods.MethodDictionary} The
new concatenated MethodDictionary.
@example
var concatenatedMethodDictionary = MethodDictionary.concat(
methodDictionary,
function () { return 'newMethod'; },
'newMethod'
);
Concatenates a MethodDictionary instance with a new method and returns a new MethodDictionary .