-A component must have a default export, but the default export is not the component
-The default export and its properties must be structured a certain way, you can't just use JavaScript
-Components, actions, animations, transitions, custom events etc must be registered, not just imported
-Components can be registered with a shorthand, because the normal way is cumbersome
-methods are attached to the prototype, and `this` is the component, even though it looks (including to linters and typecheckers) as though the `methods` object itself is the context
-Events must be method calls, not arbitrary expressions
-`event` has a special meaning in method calls, as does `this`, as does `refs`, as do `console` and other special names
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
| /* Written for MintNetwork Yukari Cluster - 500 page handling */ | |
| const bs = document.getElementById('babyshark'); | |
| /* Localize babyshark */ | |
| function localize(langCode) { | |
| const country = window.navigator.userLanguage || window.navigator.language; | |
| let ytCode = ""; | |
| const lang = langCode || country.split('-')[0]; | |
| switch (lang) { |
Suppose you have an app like this, and your bundler turns .css files into strings:
// main.js
import './x-foo.js';
import './x-bar.js';
document.body.innerHTML = ``;I'm procrastinating instead of working on a conference talk, so I decided to implement this component in Svelte to see which framework is most expressive:
Here's the original, with the addition of an import for dataUriAsSrc (and updated per @chriskrycho's comment):
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
| import matcher from 'matcher' | |
| import CORS from 'cors' | |
| let corsOptions = { | |
| origin: (origin, callback) => { | |
| let allow = false | |
| for (let allowAccessDomain of settingsData.allowAccessDomains) { // [ "*.mydomain.com"] | |
| if (matcher.isMatch(origin, allowAccessDomain)) { | |
| allow = true | |
| break |
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
| import moment from 'moment' | |
| import 'moment-duration-format' | |
| let currentMoment = moment() | |
| let currentMinuteNum = Number(currentMoment.format('mm')) | |
| let nextMin = 1 | |
| let _nextContractTime = moment(currentMoment) | |
| .add(nextMin, 'minute') |
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 paginate = (array: any, index: any, size: any) => { | |
| // transform values | |
| index = Math.abs(parseInt(index)); | |
| index = index > 0 ? index - 1 : index; | |
| size = parseInt(size); | |
| size = size < 1 ? 1 : size; | |
| // filter | |
| return [ | |
| ...array.filter((value: any, n: any) => { |
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 duplicateCheck(array: any[]) { | |
| return array.reduce((t, a) => { | |
| t[a] = (t[a] || 0) + 1; | |
| return t | |
| }, {}) | |
| } |
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 emailSecurity(userEmail: string){ | |
| const id = userEmail.split('@')[0]; | |
| const mail = userEmail.split('@')[1]; | |
| const maskingId = function(id: string) { | |
| let splitId = id.substring(0,4); | |
| for(let i = 4; i < id.length; i++) { | |
| splitId += '*'; | |
| } | |
| return splitId; | |
| }; |
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
| const getLineChartD = ({ data, size, width, padding, topSpacing }) => { | |
| const min = Math.min(...data); | |
| const max = Math.max(...data); | |
| const d = data | |
| .map((v, i) => { | |
| return `${i === 0 ? 'M' : 'L'} ${(i * (width - padding * 5)) / data.length},${ | |
| size - (v / (max - min)) * size + (topSpacing || 0) | |
| }`; | |
| }).join(' '); |
OlderNewer
