Common use of Method Contracts Clause in Contracts

Method Contracts. ‌ The method contract is another special function contract. In JavaScript, function application usually takes two arguments: a this value that binds an object for method calls and an array-like object specifying the arguments of that call. Thus, ▇▇▇▇▇▇▇’s convenience API provides a special method contract that includes a contract specification for this. For example, the sort function of the built-in Array.prototype object might be specified by a method contract which requires that sort must be called as a method of an object that is an instance of Array. The method contract further specifies that the method’s argument must be a function and that the method has to return an array. Array.prototype.sort = Contract.assert(function sort(compareFunction) { /* not specified in detail */ }, Contract.Method(InstanceOf(Array), [InstanceOf(Function)], InstanceOf(Array));

Appears in 1 contract

Sources: Dissertation

Method Contracts. ‌ The method contract is another special function contract. In JavaScript, function application usually takes two arguments: a this value that binds an object for method calls and an array-like object specifying the arguments of that call. Thus, ▇▇▇▇▇▇▇TreatJS’s convenience API provides a special method contract that includes a contract specification for this. For example, the sort function of the built-in Array.prototype object might be specified by a method contract which requires that sort must be called as a method of an object that is an instance of Array. The method contract further specifies that the method’s argument must be a function and that the method has to return an array. Array.prototype.sort = Contract.assert(function sort(compareFunction) { /* not specified in detail */ }, Contract.Method(InstanceOf(Array), [InstanceOf(Function)], InstanceOf(Array));

Appears in 1 contract

Sources: Dissertation