This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2019 The Chromium Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
// 2022-07-06 Updated to null safety | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
/// A widget that takes two children, lays them out along [axis], and allows | |
/// the user to resize them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async function() { | |
const cls1 = [ | |
'article[role="presentation"]', | |
'div[style]', | |
'div[style]', | |
'div[role="button"]', | |
'div', | |
'div[role="button"]', | |
'div[style]', | |
'img[crossorigin="anonymous"][class]', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Slashy things are single-line comments, very useful | |
/* | |
* Slashy + star are multi-line comments | |
* | |
* This is a basic inheritence example, | |
* which is a core principle of OOP, or Object Oriented Programming | |
*/ | |
// Imports let you use things from other libraries (code) | |
// that you or others have written |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const table2csv = table => { | |
const rows = [...table.querySelectorAll('tr')] | |
const csv = [] | |
if (rows.length < 20) return null | |
for (let i in rows) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isValidateEmail = email => { | |
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ | |
return re.test(String(email).toLowerCase()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const formatCurrency = (number, currency) => { | |
const options = { | |
minimumFractionDigits: 2, | |
currencyDisplay: 'narrowSymbol', | |
currencySign: 'accounting', | |
} | |
if (currency) { | |
options.style = 'currency' | |
options.currency = currency | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getLocale = () => { | |
const locale = (navigator.languages && navigator.languages.length) | |
? navigator.languages[0] | |
: navigator.language | |
return locale || 'en-US' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const snippet = (val, len = 5) => | |
(val && val.length > (len * 2)) | |
? val.substring(0, len) + '...' + val.substring(val.length - len) | |
: val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isPrimitive = val => { | |
const type = typeof val | |
if (Array.isArray(val)) return false | |
if (type === 'object') return val === null | |
return type !== 'function' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function debounce(func, wait, immediate) { | |
let timeout | |
return function (...args) { | |
clearTimeout(timeout) | |
timeout = setTimeout(() => { | |
timeout = null | |
if (!immediate) func.apply(this, args) | |
}, wait) | |
if (immediate && !timeout) func.apply(this, [...args]) | |
} |