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

myless

v0.0.18

Published

myless is a less commpile tool based on less2.5.3, add the following features for less: * support multiline string. * enable use to extend less support function through add file at specify path. * enable to extend less support function throw install

Downloads

12

Readme

myless

myless is a less commpile tool based on less2.5.3, add the following features for less:

  • support multiline string.
  • enable use to extend less support function through add file at specify path.
  • enable to extend less support function throw install npm package.
  • enable to call a java function which the jar files supported through myless.util.java.

works before install

for mac

  • install libpng by : brew install libpng. if you don't use function png8-data-uri or png8-tbcdn-uri then you can skip this step.
  • install java jdk. if you don't use svg-to-png function then you can skip this step.
  • taobao intranet user please edit file: ~/.myless/conf.json

for windows

  • install java jdk. if you don't use svg-to-png function then you can skip this step.

how to use

var fs = require('fs');
var Myless = require(myless);
var option = {ieCompat: false};
var less = new Myless({
    show_degbug_log: true, 
    max_wait_time: 5, 
    auto_close: true      // when use myless at watch mode, remove this property
});

less.parse('src/main.less', option, function(err, result){
    if(err){
        less.util.console.log('<red>parse less file error info</red>:\n <pink>%s</pink>', err);
    }else{
        fs.writeFileSync('src/main.css', result.css, 'utf8'); 
    }
});

extend functions

  • abs-path(String: pic-path)
  • pic-width(Sring: pic-path)
  • pic-h-w-rate(String: pic-path)
  • pic-height(String: pic-path)
  • png8-data-uri(String: png24-file-path)
  • png8-tbcdn-uri(String: png24-file-path). taobao intranet only!
  • tbcdn-uri(String: pic-path). taobao intranet only!
  • svg-cont(String... svg_attr, String: svg_cont). generate svg data uri by input svg attribute and svg content. for example:
   backgbround: svg-cont('width=80px', 'height=80px', <<EOF
      <!-- your svg code here -->
   EOF) center cente no-repeat;
  • svg-to-png(String: save-path, String...: svg-attrs, String: svg-cont). call apache batik to convert svg to png, return the absolute path of the png file. for example:
   backgbround: png8-data-uri(svg-to-png('./my-png.png', 'width=80px', 'height=80px', <<EOF
      <!-- your svg code here -->
   EOF)) center cente no-repeat;
  • escape-utf8(String: utf8-str). escape utf8 charactors to "\xxxx" for example:
  div:before { content: escape-utf8('中文'); }

extend grammer

  • multiline string。 you can input multiline string in the form : <{2,}(\w+)...\1, for example :
    background-iamge: svg-cont('width=80px', 'height=80px', <<CODE_END
        <!-- you svg code here -->
    CODE_END);

    background-iamge: svg-cont('width=80px', 'height=80px', <<<EOF
        <!-- you svg code here -->
    EOF);    

how to extend less function youself.

grunt-myless will crate a folder named myless at the project root path when it run first time. the folder myless has two sub-folder: data, functions。suppose we want to extend to function: fn1 and fn2, and fn1 is a sync function then fn2 is a async function.

first, we need to create two js file at the folder: "your/project/src/myless/functions". the neme of two files were : fn1.js and asy-fn2.js。the prefix asy- means is a async function.

sencod, to implements two functions as following form.

// fn1.js content
module.exports = function(myless, param1, param2){
    var sum = parseInt(param1.value, 10) + parseInt(param2.value, 10);
    return myless.util.value.toLessNum(sum, 'px');
};

// asy-fn2.js content
module.exports = function(myless, done, param1, param2){
    var sum = parseInt(param1.value, 10) + parseInt(param2.value, 10);
    setTimeout(function(){
        if(sum <= 0){
            var err = 'wrong paramaters!';
            done(err, null);
        }else{
            var ret = myless.util.value.toLessNum(sum, 'px');
            done(null, ret);
        }
    }, 1000);
};

third, use functions at you less file, for example:

div {
    width : fn1(10, 20);
    height: fn2(20, 20);    
}