source: imaps-frontend/node_modules/stylis/src/Utility.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[d565449]1/**
2 * @param {number}
3 * @return {number}
4 */
5export var abs = Math.abs
6
7/**
8 * @param {number}
9 * @return {string}
10 */
11export var from = String.fromCharCode
12
13/**
14 * @param {object}
15 * @return {object}
16 */
17export var assign = Object.assign
18
19/**
20 * @param {string} value
21 * @param {number} length
22 * @return {number}
23 */
24export function hash (value, length) {
25 return charat(value, 0) ^ 45 ? (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) : 0
26}
27
28/**
29 * @param {string} value
30 * @return {string}
31 */
32export function trim (value) {
33 return value.trim()
34}
35
36/**
37 * @param {string} value
38 * @param {RegExp} pattern
39 * @return {string?}
40 */
41export function match (value, pattern) {
42 return (value = pattern.exec(value)) ? value[0] : value
43}
44
45/**
46 * @param {string} value
47 * @param {(string|RegExp)} pattern
48 * @param {string} replacement
49 * @return {string}
50 */
51export function replace (value, pattern, replacement) {
52 return value.replace(pattern, replacement)
53}
54
55/**
56 * @param {string} value
57 * @param {string} search
58 * @param {number} position
59 * @return {number}
60 */
61export function indexof (value, search, position) {
62 return value.indexOf(search, position)
63}
64
65/**
66 * @param {string} value
67 * @param {number} index
68 * @return {number}
69 */
70export function charat (value, index) {
71 return value.charCodeAt(index) | 0
72}
73
74/**
75 * @param {string} value
76 * @param {number} begin
77 * @param {number} end
78 * @return {string}
79 */
80export function substr (value, begin, end) {
81 return value.slice(begin, end)
82}
83
84/**
85 * @param {string} value
86 * @return {number}
87 */
88export function strlen (value) {
89 return value.length
90}
91
92/**
93 * @param {any[]} value
94 * @return {number}
95 */
96export function sizeof (value) {
97 return value.length
98}
99
100/**
101 * @param {any} value
102 * @param {any[]} array
103 * @return {any}
104 */
105export function append (value, array) {
106 return array.push(value), value
107}
108
109/**
110 * @param {string[]} array
111 * @param {function} callback
112 * @return {string}
113 */
114export function combine (array, callback) {
115 return array.map(callback).join('')
116}
117
118/**
119 * @param {string[]} array
120 * @param {RegExp} pattern
121 * @return {string[]}
122 */
123export function filter (array, pattern) {
124 return array.filter(function (value) { return !match(value, pattern) })
125}
Note: See TracBrowser for help on using the repository browser.