PageSourceSearch

https://galaxystore.ru/local/templates/galaxystore/js/functions.js?17556350323035

js galaxystore.ru collected 2026-10-03 20:33:34 UTC 3,035 bytes, 75 lines download raw bytes

1//======================================= FUNCTIONS =========================================//
2
3/**
4 * @param{number} n - количество предметов
5 * @param{Array} titles - массив вариантов слова, напр. ['товар','товара','товаров']
6 * */
7if (typeof declOfNum === 'undefined') {
8    declOfNum = (n, titles) => titles[(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2)];
9}
10
11if (typeof capitalize === 'undefined') {
12    capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
13}
14
15if (typeof array_max === 'undefined') {
16    array_max = (numArray) => Math.max.apply(null, numArray);
17}
18
19if (typeof array_intersect === 'undefined') {
20    array_intersect = (array1, array2) => array1.filter(n => array2.indexOf(n) !== -1);
21}
22
23if (typeof in_array === 'undefined') {
24    in_array = (needle, array) => array.indexOf(needle) !== -1;
25}
26
27if (typeof distinct === 'undefined') {
28    distinct = (value, index, self) => self.indexOf(value) === index;
29}
30
31if (typeof array_distinct === 'undefined') {
32    array_distinct = (array) => array.filter(distinct);
33}
34
35if (typeof array_merge === 'undefined') {
36    array_merge = (array1, array2) => array1.concat(array2);
37}
38
39if (typeof array_merge_unique === 'undefined') {
40    array_merge_unique = (array1, array2) => array_distinct(array_merge(array1, array2));
41}
42
43/**
44 * проверяет, существует ли вложенный путь в обьекте, массиве или строке
45 * формат вызова checkPath({a:{b:{c:{}}}},'a','b','c'), checkPath(['a',['b',['c']]],0,1,0)
46 * для обьектов идет по ключам, для массивов и строк - по индексам
47 * возвращает true/false
48 * https://stackoverflow.com/questions/2631001/test-for-existence-of-nested-javascript-object-key
49 * */
50if (typeof checkPath === 'undefined') {
51    checkPath = (obj, level, ...rest) => {
52        if (obj === undefined) return false;
53        if (rest.length == 0 && obj.hasOwnProperty(level)) return true;
54        return checkPath(obj[level], ...rest);
55    }
56}
57
58/**
59 * возвращает вложенное значение по пути в обьекте, массиве или строке
60 * формат вызова getPath({a:{b:{c:{}}}},'a','b','c'), getPath(['a',['b',['c']]],0,1,0)
61 * для обьектов идет по ключам, для массивов и строк - по индексам
62 * возвращает значение или undefined
63 * https://stackoverflow.com/questions/2631001/test-for-existence-of-nested-javascript-object-key
64 * */
65if (typeof getPath === 'undefined') {
66    getPath = (obj, level, ...rest) => {
67        if (obj === undefined) return undefined;
68        if (rest.length == 0 && obj.hasOwnProperty(level)) return obj[level];
69        return getPath(obj[level], ...rest);
70    }
71}
72
73if (typeof newUUID === 'undefined') {
74    newUUID = () => (new Date).getTime().toString(36);
75}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.