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

resutiles

v1.0.0

Published

node v0.8+ TexturePacker 精灵图打包工具

Downloads

1

Readme

#环境依赖 node v0.8+ TexturePacker 精灵图打包工具

#部署步骤

  1. 使用TexturePacker精灵图打包工具将所有小图进行打包, 要求不能旋转,图片名称不带后缀,图片的大小符合2的n次幂宽高近似最小比例 要求打包后的图片必须是png格式,打包后的配置文件是json或者xml格式

  2. npm i resutile --save

  3. 使用import 或者require导入

  4. 使用webpack或者gulp打包输出

#目录结构描述 ├── Readme.md // help ├── package.json // 配置 ├── ResUtile.js // 方法名

#版本 v1.1.1 1. 实现加载多个精灵图配置文件后,根据图片名称获取一个div 以该图片为背景,大小是图片原尺寸的div元素。不允许重设宽高 可使用样式中的缩放更改。 2、可以实现根据新图片名称替换div的背景为新图 3、提供根据图片名称获取该图片的坐标位置,图片的大小等对象 数据 4、可以允许用户配置文件是json或者xml 注: 1、内含一个给对象合并方法,与Object.assign类似,但是可以做 深度合并。 2、内含一个ES5的继承方法

#V1.0.0 版本案例 ##导入插件 import Res from "./node_modules/resutile/ResUtile" ##初始化Res ###第一个参数是所有需要使用的精灵图名称,可以有多个,使用数组 ###第二个参数是精灵图对应该js的相对地址 ###第三个参数是精灵图配置文件的类型,json或者xml ###第四个参数是加载完成精灵图后的回调函数,回调函数中带一个参数list是所有加载的配置文件集合 Res.init(["bird","plane"],"img/","json",loadHandler); ###使用Res.getImage("图片名称"),就可以获得该图片对应的div,使用Res.changeImg(需要替换的div,“图片名称”)就可以给div替换背景图是这个精灵图 function loadHandler(list){
var div=Res.getImage("enemy1_blowup_2"); document.body.appendChild(div); Res.changeImg(div,"enemy1_fly_1") }

##也可以在初始化的时候不填写第四个参数,使用事件侦听获取

document.addEventListener(Res.DATA_FINISH_EVENT,loadHandler); Res.init(["bird","plane"],"img/","json"); function loadHandler(e){
var div=Res.getImage("enemy1_blowup_2"); document.body.appendChild(div); Res.changeImg(div,"enemy1_fly_1") }

##对象深度合并 var obj={a:1,b:2,d:{a:[1,2,3]}}; var obj2={c:3}; ###对象.addProto(需要合并的对象);
obj2.addProto(obj); console.log(obj2);

##也可用于ES5面向对象中原型添加内容 ###优点在于继承后的类添加原型方法时可以同时添加若干个 function Box(){

}
Box.prototype.addProto({
    a:1,
    b:2,
    c:function(){

    },
    d:function(){

    }
})

##ES5继承方法 function Box(参数){

} Box.prototype={ constructor:Box, a:1, b:2, c:function(){

}

} function Ball(参数){ Box.call(this,参数) } ###让Ball继承Box Ball.extendClass(Box); Ball.prototype.addProto({ d:function(){

},
e:[1,2,3]

})