This file contains 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 MagicString from "magic-string"; | |
/** | |
* Automatically insert ZWSP into text. | |
* @param {string} value | |
* @param {string | undefined} sep | |
* @returns {string} | |
*/ | |
export function insertZeroWidthSpace(value, sep = '\u200b') { |
This file contains 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
/* | |
* Tiny tokenizer | |
* | |
* - Accepts a subject string and an object of regular expressions for parsing | |
* - Returns an array of token objects | |
* | |
* tokenize('this is text.', { word:/\w+/, whitespace:/\s+/, punctuation:/[^\w\s]/ }, 'invalid'); | |
* result => [{ token="this", type="word" },{ token=" ", type="whitespace" }, Object { token="is", type="word" }, ... ] | |
* | |
*/ |
This file contains 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
/** | |
* Designed and developed by Seanghay Yath (@seanghay) | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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 segmenter = new Intl.Segmenter("km", {granularity: "word"}); | |
const input = "នឹកបងឬនឹកគេ?"; | |
const segments = segmenter.segment(input); | |
for (const {segment} of segments) { | |
console.log(segment) | |
} | |
// OUTPUT: | |
// នឹក |
This file contains 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 androidx.annotation.IntRange; | |
import androidx.annotation.NonNull; | |
import androidx.annotation.Nullable; | |
import androidx.annotation.VisibleForTesting; | |
import java.text.DecimalFormat; | |
import java.text.DecimalFormatSymbols; | |
import java.text.NumberFormat; | |
import java.util.Currency; | |
import java.util.Locale; |
This file contains 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 org.junit.Assert.assertEquals | |
import org.junit.Assert.assertNull | |
import org.junit.Test | |
import kotlin.jvm.Throws | |
class PhoneNumberSanitizerTest { | |
@Test | |
fun `COUNTRY_CODE should be +855`() { | |
assertEquals("+855", PhoneNumberSanitizer.COUNTRY_CODE) |
This file contains 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 android.os.Looper | |
import android.view.LayoutInflater | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleObserver | |
import androidx.lifecycle.OnLifecycleEvent | |
import androidx.viewbinding.ViewBinding | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty |
This file contains 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
class HomeFragment : Fragment() { | |
private var _binding: FragmentHomeBinding? = null | |
private val binding: FragmentHomeBinding get() = _binding!! | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View? { |
This file contains 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
class MainActivity : AppCompatActivity() { | |
private val binding by viewBinding(ActivityMainBinding::inflate) | |
} |