Skip to content

Commit fc16092

Browse files
committed
01-spy-decorator
1 parent 71fa440 commit fc16092

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function spy(func) {
2-
// your code
2+
// ваш код
33
}
44

55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Here we can use `calls.push(args)` to store all arguments in the log and `f.apply(this, args)` to forward the call.
1+
Здесь мы можем использовать `call.push(args)` для хранения всех аргументов в списке и `f.apply(this, args)` для переадресации вызова.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
importance: 5
1+
важность: 5
22

33
---
44

5-
# Spy decorator
5+
# Декоратор шпион
66

7-
Create a decorator `spy(func)` that should return a wrapper that saves all calls to function in its `calls` property.
7+
Создайте декоратор `spy(func)`, который должен возвращать обёртку, которая сохраняет все вызовы функции в своем свойстве `Call`.
88

9-
Every call is saved as an array of arguments.
9+
Каждый вызов должен сохраняться как массив аргументов.
1010

11-
For instance:
11+
Например:
1212

1313
```js
1414
function work(a, b) {
15-
alert( a + b ); // work is an arbitrary function or method
15+
alert( a + b ); // произвольная функция или метод
1616
}
1717

1818
*!*
@@ -27,4 +27,4 @@ for (let args of work.calls) {
2727
}
2828
```
2929

30-
P.S. That decorator is sometimes useful for unit-testing. Its advanced form is `sinon.spy` in [Sinon.JS](http://sinonjs.org/) library.
30+
P.S.: Этот декоратор иногда полезен для юнит-тестирования. Его расширенная форма - `sinon.spy` содержится в библиотеке [Sinon.JS] (http://sinonjs.org/).

0 commit comments

Comments
 (0)