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

berserk-js

v1.0.3

Published

Berserk.js , a lightweight and progressive MVVM framework

Downloads

2

Readme

Berserk.js

facebook_cover_photo_2

Berserk.js

一款渐进式 MVVM 轻量级框架(Berserk取自《剑风传奇》的英文名)

1. 快速上手

  1. 通过cdn引入Berserk
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.js"></script>
  1. 创建一个app对象
const App = B.createApp(`
    <div>
        My name is: 
        <span b-bind="test"></span>
    </div>
`);
  1. 设置响应式数据
App.useReactive({
    name: 'panda'
});
  1. 添加方法
App.register('handleClick', () => {
    console.log('this is a func');
    App.states.name = 'cat';
});
  1. 将该组件定义到全局Berserk对象中
B.define('app', App);
  1. 当组件编译完成后,将组件添加到当前DOM树中
App.onMount(() => {
    console.log('this is mounted');
    document.querySelector('#root').appendChild(window.Berserk.app);
});

2. 设计思想

我没有深入接触过vue,但是MVVM是现代前端领域的重要思想,故自己动手写一个MVVM简易框架来加深对此的理解

  • MVVM

Berserk的响应式基础是Object.defineProperty,通过观察者模式,进行依赖收集,在必要时进行更新,实现双向数据绑定(Two-way data binding)。

  • template

HTML部分由模板字符串直接生成至真实DOM,再通过递归对每一个元素添加Berserk api的能力。

  • component

Berserk是将所有声明过的组件都注册在window.Berserk这个对象里,这样将有利于组件间的任意调用和外部组件的引入。