npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-adaptive-utils

v0.0.4

Published

React-Native adaptive utils, contains various adaptation function.

Downloads

20

Readme

English | 简体中文

react-native-adaptive-utils

Install

npm install react-native-adaptive-utils

Import

import { YourNeed } from "react-native-adaptive-utils";

Demo

Such as, import debounce function.

import { debounce } from "react-native-adaptive-utils";

API

1 Improve tools.

1.1 debounce

The appointed time(default 500ms ),trigger many times that execute last once.

Demo

debounce(() => {
  console.log(1);
}, 500);

Means if trigger many times in 500ms, execute last once.

1.2 throttle

The appointed time(default 500ms ), ignored triggers after first once executed.

Demo

throttle(() => {
  console.log(1);
}, 500);

Means execute first once, then if trigger many times in 500ms, ignored.

1.3 randomString

Generates a random string of a specified length (32 bits by default).

Demo

let randomStr = randomString(16);

Above generate '16' length random number.

1.4 integerDecimalsFormat

The integer is displayed in thousands of fractions

Demo

let thousandsNum = integerDecimalsFormat(-456123131.12301);

The above num format is' -456,123,131.12301 '

1.5 computeSomeCharsCount

Counts the number of occurrences of a specified character or string in a string

Demo

let count = computeSomeCharsCount("ad", "adsfdasf");

The count above is the number of occurrences of 'AD' in 'adsfdasf'

1.5 allSettled

Encapsulated in the rn Promise.all () simulation Promise.allSettled ()

Demo

allSettled(['promiseA','promiseB',...])

Returns an array containing the success or failure returns of all Promises

2 validator

2.1 validPhone

Verify phone no.

Demo

let checkPhoneFlag = validPhone(12);

2.2 validEmail

Verify E-mail.

Demo

let checkEmailFlag = validEmail(12);

2.3 validCardNo

Verify Chinese card no.

Demo

let checkCardNoFlag = validCardNo(12);

2.4 strLimit

Character length limit verification

Demo

let text = limitStr(str, length);

2.5 isImg

Image type verification

Demo

let isPicture = isImg(target);

3 Resolution

3.1 dynamicFontSize

Get font size base on width.

Demo

let fontSize = dynamicFontSize(12);

Suggest Usage:

const styles = StyleSheet.create({
  container: {
    fontSize: dynamicFontSize(12)
  }
});

3.2 isIphoneX

Check whether it is iphonex

Demo

isIphoneX() ? "..." : "...";
const styles = StyleSheet.create({
  container: {
    height: isIphoneX() ? 15 : 20;
  }
});
### 3.3 getTitleBarHeight

Gets the title bar height based on the current screen.

#### Demo
let height = getTitleBarHeight();
const styles = StyleSheet.create({
  container: {
    height: getTitleBarHeight();
  }
});

Todo List

  • [x] Get image type.
  • [x] Determines the upper limit of input characters in the text box.
  • [x] Generate UUID.

Todo Prepare

  • [ ] Network tool.
  • [ ] RN-allSettled