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

plp

v1.0.4

Published

## Create

Downloads

1,386

Readme

plp

Create

_.create('div');
_.create('div.header');
_.create('.header');

Common

aliases(object, propertyName, aliases...)

Определяет в объекте object свойства-псеводнимы с именами aliases, всегда возвращающие значение свойства propertyName объекта object.

var data = {
  a: 1,
};

plp.aliases(data, 'a', 'a1');

console.log(data.a1); // 1

data.a = 2;

console.log(data.a1); // 2

append(array, items...)

Добавляет один или несколько элементов items в конец массива array.

var numbers = [1, 2, 3];

plp.append(numbers, 4, 5, 6);

console.log(numbers); // [1, 2, 3, 4, 5, 6]

basename(path)

Возвращает базовое имя файла path.

var name = plp.basename('/etc/nginx/nginx.conf');

console.log(name); // nginx.conf

buildData()

camelcase(str)

Возвращает строку str, преобразованную в формат camelCase.

console.log(plp.camelcase('ui-button')); // uiButton

capitalize(str)

Возвращает строку str, первый символ которой приведен к верхнему регистру.

console.log(plp.capitalize('button')); // Button

clone(object, deep = false)

Копирует объект object и возвращает скопированный объект. Если аргумент deep имеет истинное значение, осуществляется глубокое копирование.

var data1 = {
  a: 1
};

var data2 = plp.clone(data1);

console.log(data2); // { a: 1 }

concatArrays(arrays)

Выполняет конкатенацию массивов arrays. Возвращает новый массив.

var arrays = [
  [1, 2, 3],
  [4, 5, 6]
];

console.log(plp.concatArrays(arrays)); // [1, 2, 3, 4, 5, 6]

dasherize(str)

Возвращает строку str, все слова которой разделены символами -.

var str = plp.dasherize('uiButton');

console.log(str); // ui-button

deepClone(object)

Выполняет глубокое копирование объекта object, возвращает копию.

var data1 = {
  a: 1,
  b: {
    b1: 2,
  }
};

var data2 = plp.deepClone(data1);

console.log(data2); // { a: 1, b: { b1: 2 } }

defaults(data, defaultData)

Возвращает новый объект, содержащий все свойства объекта defaultData, расширенный объектом data.

var opts = plp.defaults(options, {
  username: '',
  password: ''
});

each(collection, iterator)

Выполняет функцию iterator для каждого элемента коллекции collection.

plp.each([1, 2, 3], (number, i) => {

});

var data = {
  a: 1,
  b: 2,
};
plp.each(data, (value, name) => {

});

ensureArray(items...)

Возвращает массив, состоящий из элементов items. Если элемент items является массивом, он конкатенируется с возвращаемым массивом.

console.log(plp.ensureArray(1)); // [1]

console.log(plp.ensureArray([1])); // [1]

console.log(plp.ensureArray(1, [2])); // [1, 2]

EventEmitter()

Класс EventEmitter, содержащий методы emit, on, once и т.д.

class Component extends plp.EventEmitter {

  constructor () { super();
    var self = this;
  }

}

exclude(data, names, bindMethods = false)

Возвращает копию объекта data, из которого исключены все свойства с именами names. Если аргумент bindMethods имеет истинное значение, методы возвращаемого объекта будут автоматически привязаны к контексту data.

var data = {
  a: 1,
  b: 2
};

console.log(plp.exclude(data, ['b'])) // { a: 1 };

expression(code, locals = {})

Выполняет выражение code в замыкании, включающем переменные locals. Возвращает результат выражения.

console.log(plp.expression('a + 9', { a: 3 })); // 12

extend(destination, sources...)

Расширяет объект destination объектами sources. Возвращает объект destination.

console.log(plp.extend({ a: 1 }, { b: 2 })); // { a: 1 }

extname(path)

Возвращает расширение файла path, начинающиеся с точки, или пустую строку, если расширение отсутствует.

console.log(plp.extname('/etc/nginx/nginx.conf')); // .conf

filesize()

flattenArray(array)

Возвращает массив, состоящий из конкатенированных элементов массива array с уплощенной структурой, т.е. каждый элемент-массив с учетом вложенных элементов конкатенируется с результатом.

console.log(plp.flattenArray([1, 2, [3, 4, [5, 6]]])); // [1, 2, 3, 4, 5, 6]

flatten(collection)

Копирует объект или массив collection с приведением структуры к уплощенному виду. Если аргумент является массивом, просто вызывает функцию flattenArray и возвращает результат.

var data = {
  a: {
    b: {
      c: 1
    }
  }
};
console.log(plp.flatten(data)); // { 'a.b.c': 1 }

fn()

getClassDescription()

getClass()

getExtendedClass()

getFunctionArgs()

getFunctionBody()

getStandardTags()

getTypes()

get()

global()

ifEmpty()

ifNotEmptyMany()

ifNotEmpty()

indent()

indexof()

inspect()

isArray()

isClass()

isEmpty()

isEqual()

isStardardTag()

is()

json()

keys()

mapProperty()

nameValuePair()

notEmpty()

parallel()

parseArguments()

path()

pick()

prepend()

protoAliases()

query()

queue()

rand()

random()

range()

re()

regFromString()

renderAttrs()

repeatString()

repeat()

sample()

sanitize()

set()

sort()

sortby()

spliceFirst()

spliceLast()

splice()

splitArray()

storeData()

store()

template()

toArray()

trimFilename()

trim()

type()

unflatten()

uniq()

uniqueId()

values()

wrapObject()

function afterElement(target, child)

Arguments

  • target: HTMLElement, ;
  • child: HTMLElement, ;

function aliases

Hello, world!

Example

import aliases from 'plp/aliases';
aliases(date, 'getTime', 'time', 'times');

Arguments

  • data: Object, Plain object with data;
  • name: String, ;

Return

  • data: Object, ;

function animator(elem)

function appendElement(parent, child)

function appendScript(url)

function append(items, ...vals)

function base64(input)

function beforeElement(target, child)

function camelcase(str)

function clone(data, [deep])

function each(items, cb)