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

@mlhiter/laura

v1.0.0

Published

a micro javascript framework to build WebUI

Downloads

4

Readme

一,框架基本做了什么?

1,响应性(Reactivity)

//without
<p id="cool-para"></p>
<script>
  const coolPara = 'Lorem ipsum.';
  const el = document.getElementById('cool-para');
  el.innerText = coolPara;
</script>

//with(Vue)
<script setup>
  const coolPara = 'Lorem ipsum.';
</script>
<template>
  <p>{{ coolPara }}</p>
</template>

//or(React)
export default function Para() {
  const coolPara = 'Lorem ipsum';
  return <p>{ coolPara }</p>;
}

可以看到书写的代码量大大减少,但是这不是主要原因;

主要原因是这将UI和数据绑定组合在一起,我们只需要更改script里的数据即可更新template里的UI显示。

2,组合性(Composability)

//with
<!-- Defining the component -->
<component name="cool-para">
  <p>
    <content />
  </p>
</component>

<!-- Using the component -->
<cool-para>Lorem ipsum.</cool-para>

我们可以通过定义组件并且在不同的地方重用它来提高复用率,就像定义函数使用函数一样,但是这是在原始的HTML情况下不具有的。

3,模板化(templating)

Vue中的template和React中的JSX的Component,用来展示的部分就是模板。

为什么称为模板呢,因为它的数据是可变的,其他非数据部分不变,数据部分变就像模板一样喽。

4,虚拟DOM(virtual DOM)

一种概念或者技术,简单的说就是我们虚构出一个DOM树存在内存里,当我们更新数据的时候,虚拟DOM树会检查自己哪里发生改变,然后仅改变真正DOM树的这一部分。

为什么要在数据与真实DOM之间加上这样一层虚拟DOM呢?因为如果直接操控真实DOM经常会产生非常大的改变,损耗性能而且慢。而我们通过虚拟DOM可以做到仅改变我们想要改变的那一小部分的真实DOM,并且虚拟DOM存在内存里的代价是相对较小的(比直接操控真实DOM小)。

5,状态管理(state management)

状态是框架的本质,状态的改变会导致相应的组件使用状态的新值来重新渲染其模板。

#参考文章

Building a Frontend Framework; Reactivity and Composability With Zero Dependencies --- 构建前端框架;零依赖性的反应性和可组合性 (18alan.space)

Frontend framework --- 前端框架 (mfrachet.github.io)