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

ali-ltcom-ltao-u-utils

v3.3.11

Published

ltcom-ltao-u-utils

Downloads

4

Readme

Badges

Build status Line coverage Branch coverage TNPM version TNPM downloads


how to use

import { mtop, viewport, util, tracker } from '@ali/ltcom-ltao-u-utils';

const queryData = (params) => {
  return mtop({
    api: 'mtop.ltao.interaction.platform.api',
    v: '1.0',
    data: params
  });
}

viewport();

const {
  headerBarHeight,
  headerTotalHeight,
  nativeBackListener,
  nativeGoBack,
  openWindow,
  goldLogExp,
  goldLogClk,
} = util;

util 说明

|属性|类型|描述| |:---------------|:--------|:----------| |spmArr|array|[a, b]码]| |isAndroid|bool|是否是安卓| |headerBarHeight|number|头部刘海区域的高度| |headerTotalHeight|number|整体头部的高度| |isLTApp|function|返回是否是特价版| |isLiteLTApp|function|返回是否是特价版极简包| |isOfficialLTApp|function|返回是否是特价版正式包| |getTtid|function|获得用户的ttid| |isDebugAll|function|是否是debug模式| |getUrlParams|function(url = window.location.href)|获取url上所有query的对象| |query|function(name, url = window.location.href)|获取url上指定参数的值| |getDataFromArray|function(key, value, arr)|在数组上找到指定key=value的对象| |formatBool|function(value)|将value转化为bool| |openLTApp|function(channelId)|唤端, 自定义频道id| |throttle|function(fn, delay = 300)|防抖| |toast|function(message = '', delay = 1500, options = {})|toast防抖| |goldLogExp|function(key, param)|黄金令箭曝光| |goldLogClk|function(key, param)|黄金令箭点击| |setLocalStorage|function(name, value, expires)|设置ls, expires为设置过期的毫秒数 | |getLocalStorage|function(name)|获取ls| |nativeGoBack|function|回退| |openWindow|function(link, spmc, spmd)|打开一个链接| |replaceWindow|function(link, spmc, spmd)|replace的方式打开一个链接| |nativeBackListener|function|监听返回的回调事件| |setCustomPageTitle|function(params)|设置native的title| |setNavBarStyle|function(params)|设置native头部样式| |setStatusBarStyle|function(params)|设置状态栏样式|

tracker 说明

import { tracker } from '@ali/ltcom-ltao-u-utils';

const {
  loadingStartTrigger,           // 记录loadingstart的时间,只记录不上报
  loadingEndTrigger,             // 记录loadingend的时间,只记录不上报
  firstScreenCompletedTrigger,   // 记录首屏加载完成的时间, 也会上报fsTime,只记录不上报
  fsTimeTrigger,                 // 记录fsTime的时间,优先级高于firstScreenCompleted上报的值,只记录不上报
  pushTracker,                   // 一次性上报之前记录的时间,参数为采样率的分母
} = tracker;

useEffect(() => {
  // 比如:认为 dom 出来的时候,就是loading开始的时间点
  loadingStartTrigger();
}, []);

useEffect(() => {
  // 比如:认为在页面的loading隐藏的时候,记录时间点
  if (!isLoading) {
    loadingEndTrigger();
  }
}, [isLoading]);

useEffect(() => {
  // 比如:认为请求返回的时候,认为是页面加载完成,记录时间点
  // 并发送上报的请求
  if (!isLoading) {
    firstScreenCompletedTrigger();
    pushTracker();
  }
}, [applyFinish]);

|方法名|参数|描述| |:---------------|:--------|:----------| |loadingStartTrigger|(duration)|传入performance的时间长度,默认为performance.now()| |loadingEndTrigger|(duration)|传入performance的时间长度,默认为performance.now()| |firstScreenCompletedTrigger|(duration, unInteractive)|传入performance的时间长度,默认为performance.now(), unInteractive: 自动上传interactive数据,默认false,true时不上传| |fsTimeTrigger|(duration)|传入performance的时间长度,默认为performance.now()| |pushTracker|(sampling = 10)|传入采样率的分母,如传入5,则采样率为1/5 = 20%| |interactiveTrigger|()|手动上传interactive数据|