Skip to content

Commit 764d538

Browse files
committed
Translated most parts
1 parent 6de81a0 commit 764d538

File tree

7 files changed

+154
-151
lines changed

7 files changed

+154
-151
lines changed

1-js/99-js-misc/01-proxy/01-error-nonexisting/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function wrap(target) {
1010
if (prop in target) {
1111
return Reflect.get(target, prop, receiver);
1212
} else {
13-
throw new ReferenceError(`Property doesn't exist: "${prop}"`)
13+
throw new ReferenceError(`Özellik yok: "${prop}"`)
1414
}
1515
}
1616
});
@@ -19,5 +19,5 @@ function wrap(target) {
1919
user = wrap(user);
2020

2121
alert(user.name); // John
22-
alert(user.age); // Error: Property doesn't exist
22+
alert(user.age); // Hata: Özellik yok
2323
```
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11

2-
# Error on reading non-existant property
2+
# Mevcut olmayan özelliği okuma hatası
33

4-
Create a proxy that throws an error for an attempt to read of a non-existant property.
4+
Mevcut olmayan bir özelliği okumaya çalışıldığında hata fırlatan bir proxy oluşturun.
55

6-
That can help to detect programming mistakes early.
6+
Bu, programlama hatalarını erken tespit etmeye yardımcı olabilir.
77

8-
Write a function `wrap(target)` that takes an object `target` and return a proxy instead with that functionality.
9-
10-
That's how it should work:
8+
Bir nesne `target` alan ve bu işlevselliğe sahip bir proxy döndüren `wrap(target)` fonksiyonunu yazın.
9+
Şöyle çalışmalı:
1110

1211
```js
1312
let user = {
@@ -17,7 +16,7 @@ let user = {
1716
function wrap(target) {
1817
return new Proxy(target, {
1918
*!*
20-
/* your code */
19+
/* kodunuz */
2120
*/!*
2221
});
2322
}
@@ -26,6 +25,6 @@ user = wrap(user);
2625

2726
alert(user.name); // John
2827
*!*
29-
alert(user.age); // Error: Property doesn't exist
28+
alert(user.age); // Hata: Özellik yok
3029
*/!*
3130
```

1-js/99-js-misc/01-proxy/02-array-negative/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ let array = [1, 2, 3];
55
array = new Proxy(array, {
66
get(target, prop, receiver) {
77
if (prop < 0) {
8-
// even if we access it like arr[1]
9-
// prop is a string, so need to convert it to number
8+
// buna arr[1] gibi erişsek bile
9+
// prop bir yazıdır(string), o zaman onu bir numaraya(number) çevirmeliyiz
1010
prop = +prop + target.length;
1111
}
1212
return Reflect.get(target, prop, receiver);
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11

2-
# Accessing array[-1]
2+
# array[-1]'e Erişmek
33

4-
In some languages, we can access array elements using negative indexes, counted from the end.
4+
Bazı dillerde, dizi elemanlarına sondan sayılarak negatif indekslerle erişebiliriz.
55

6-
Like this:
6+
Şöyle:
77

88
```js
99
let array = [1, 2, 3];
1010

11-
array[-1]; // 3, the last element
12-
array[-2]; // 2, one step from the end
13-
array[-3]; // 1, two steps from the end
11+
array[-1]; // 3, son eleman
12+
array[-2]; // 2, sondan bir önceki eleman
13+
array[-3]; // 1, sondan iki önceki eleman
1414
```
1515

16-
In other words, `array[-N]` is the same as `array[array.length - N]`.
16+
Başka bir deyişle, `array[-N]` ifadesi `array[array.length - N]` ile aynıdır.
1717

18-
Create a proxy to implement that behavior.
18+
Bu davranışı uygulamak için bir proxy oluşturun.
1919

20-
That's how it should work:
20+
Şöyle çalışmalı:
2121

2222
```js
2323
let array = [1, 2, 3];
2424

2525
array = new Proxy(array, {
26-
/* your code */
26+
/* kodunuz */
2727
});
2828

2929
alert( array[-1] ); // 3
3030
alert( array[-2] ); // 2
3131

32-
// Other array functionality should be kept "as is"
32+
// Geri kalan dizi(array) özelliği "olduğu gibi" kalmalıdır
3333
```

1-js/99-js-misc/01-proxy/03-observable/solution.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
The solution consists of two parts:
1+
Çözüm iki bölümden oluşur:
22

3-
1. Whenever `.observe(handler)` is called, we need to remember the handler somewhere, to be able to call it later. We can store it right in the object, using our symbol as the key.
4-
2. We need a proxy with `set` trap to call handlers in case of any change.
3+
1. `.observe(handler)` çağrıldığında, handler'ı daha sonra çağırabilmek için bir yerde saklamamız gerekir. Bunu, sembolümüzü anahtar olarak kullanarak doğrudan nesnede saklayabiliriz.
4+
2. Herhangi bir değişiklik durumunda handler'ları çağırmak için `set` tuzağına sahip bir proxy'ye ihtiyacımız var.
55

66
```js run
77
let handlers = Symbol('handlers');
88

99
function makeObservable(target) {
10-
// 1. Initialize handlers store
10+
// 1. Handler'ları saklamak için alanı başlat
1111
target[handlers] = [];
1212

13-
// Store the handler function in array for future calls
13+
// Handler fonksiyonunu ileride çağırmak için diziye ekle
1414
target.observe = function(handler) {
1515
this[handlers].push(handler);
1616
};
1717

18-
// 2. Create a proxy to handle changes
18+
// 2. Değişiklikleri yakalamak için bir proxy oluştur
1919
return new Proxy(target, {
2020
set(target, property, value, receiver) {
21-
let success = Reflect.set(...arguments); // forward the operation to object
22-
if (success) { // if there were no error while setting the property
23-
// call all handlers
21+
let success = Reflect.set(...arguments); // İşlemi nesneye ilet
22+
if (success) { // Özellik atanırken hata yoksa
23+
// Tüm handler'ları çağır
2424
target[handlers].forEach(handler => handler(property, value));
2525
}
2626
return success;
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
# Observable
2+
# Gözlemlenebilir (Observable)
33

4-
Create a function `makeObservable(target)` that "makes the object observable" by returning a proxy.
4+
Bir nesneyi "gözlemlenebilir" yapan ve bir proxy döndüren `makeObservable(target)` fonksiyonunu oluşturun.
55

6-
Here's how it should work:
6+
Şöyle çalışmalı:
77

88
```js run
99
function makeObservable(target) {
10-
/* your code */
10+
/* kodunuz */
1111
}
1212

1313
let user = {};
@@ -20,10 +20,9 @@ user.observe((key, value) => {
2020
user.name = "John"; // alerts: SET name=John
2121
```
2222

23-
In other words, an object returned by `makeObservable` has the method `observe(handler)`.
23+
Başka bir deyişle, `makeObservable` tarafından döndürülen nesnede `observe(handler)` metodu bulunur.
2424

25-
Whenever a property changes, `handler(key, value)` is called with the name and value o the property.
25+
Bir özelliğin değeri değiştiğinde, ilgili özelliğin adı ve değeri ile `handler(key, value)` çağrılır.
2626

27-
28-
P.S. In this task, please handle only writing to a property. Other operations can be implemented in a similar way.
29-
P.P.S. You might want to introduce a global variable or a global structure to store handlers. That's fine here. In real life, such function lives in a module, that has its own global scope.
27+
Not: Bu görevde yalnızca bir özelliğe değer atamayı (yazmayı) ele alın. Diğer işlemler benzer şekilde uygulanabilir.
28+
Ek Not: Handler'ları saklamak için global bir değişken veya global bir yapı kullanabilirsiniz. Burada bu uygundur. Gerçek hayatta, böyle bir fonksiyon kendi global kapsamına sahip bir modülde yaşar.

0 commit comments

Comments
 (0)