Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boladao

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boladao - npm Package Compare versions

Comparing version 0.0.0 to 1.0.0

114

index.js
'use strict';
/*!
* acany
* boladao
* Copyright (c) 2016 heyderpd <heyderpd@gmail.com>

@@ -9,88 +9,58 @@ * MIT Licensed

var middle = function middle(word) {
return '*' + word + '*';
};
var _require = require('pytils');
var ___ASTERISK___ = String.fromCharCode(254);
var length = _require.length;
var searchSimple = function searchSimple(word) {
return middle(word.replace('*', '\\*').replace(/\ +/gim, '**'));
var DICT = require('dictany');
var tendentious = require('random-tendentious');
var keys = {
first: ['verbo', 'normal', 'pouco', 'muito'],
second: ['eu', 'nos']
};
var searchComplex = function searchComplex(word) {
return middle(word.replace('*', ___ASTERISK___).replace(/\ +/gim, '').split('').join('**').replace(___ASTERISK___, '\\*'));
var randomFirst = function randomFirst() {
return Math.floor(tendentious({
f: Math.random,
l: [1, length(keys.first) + 1.5] })());
};
var findAnyMatch = function findAnyMatch(anyneed, setList, limit) {
if (limit <= 0) return [];
var randomSecond = function randomSecond() {
return Math.floor(tendentious({
f: Math.random,
l: [1, length(keys.second) + 1.5] })());
};
var list = copy(setList);
var found = {};
var foundCount = 0;
var ref = void 0;
while (foundCount < limit && length(list) > 0) {
var item = list.shift();
if ((ref = anymatch(anyneed, item, true)) >= 0) {
if (!hasProp(found, ref)) {
found[ref] = [];
}
found[ref].push(item);
foundCount++;
}
}
return found;
var getWords = function getWords(level, position) {
return keys[level][position];
};
var concatResult = function concatResult(results) {
var found = [];
eachVal(results, function (maths) {
if (length(maths) > 0) {
eachVal(maths, function (item) {
found.push(item);
});
}
});
return found;
var getSeed = function getSeed() {
return [getWords('second', randomSecond()), getWords('first', randomFirst())].join(' ');
};
var doSearch = function doSearch(need, list, limit) {
var anyneed = [need, searchSimple(need), searchComplex(need)];
var DicionarioBoladao = DICT({
'*verbo*': 'bolar',
'*normal*': DICT({
'*eu*': 'bolado',
'*nos*': 'bolados',
'DEFAULT': 'bolando?'
}),
'*pouco*': DICT({
'*eu*': 'boladinho',
'*nos*': 'boladinhos',
'DEFAULT': 'bolacha?'
}),
'*muito*': DICT({
'*eu*': 'boladão',
'*nos*': 'boladões',
'DEFAULT': 'biscoito?'
}),
'DEFAULT': 'boladamente?'
});
var found = findAnyMatch(anyneed, copy(list), limit);
return concatResult(found);
};
var main = function main() {
var setNeed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
var setList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var setLimit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var list = isArray(setList) && length(setList) > 0 ? copy(setList) : undefined;
if (list === undefined) throw new Error("var 'list' have a invalid value");
var need = isString(setNeed) ? setNeed : undefined;
if (need === undefined) throw new Error("var 'need' have a invalid value");
if (length(need) <= 0) return setList;
var limit = isNumber(setLimit) && setLimit > 0 ? setLimit : undefined;
if (limit === undefined) throw new Error("var 'limit' have a invalid value");
return doSearch(need, list, limit);
return DicionarioBoladao(getSeed());
};
var _require = require('pytils');
var isNumber = _require.isNumber;
var isString = _require.isString;
var isArray = _require.isArray;
var length = _require.length;
var copy = _require.copy;
var eachVal = _require.eachVal;
var arrayDiff = _require.arrayDiff;
var hasProp = _require.hasProp;
var anymatch = require('anymatch');
module.exports = main;
{
"license": "MIT",
"name": "boladao",
"version": "0.0.0",
"description": "boladao",
"version": "1.0.0",
"description": "heyder boladao",
"main": "index.js",
"scripts": {},
"keywords": [
"heyder",
"boladao"

@@ -20,3 +21,6 @@ ],

"devDependencies": {},
"dependencies": {}
"dependencies": {
"dictany": "^1.1.0",
"random-tendentious": "^1.0.2"
}
}

@@ -1,42 +0,7 @@

# acany : simple support to autocomplete. receve a list and a word
# return a list math in sort of less diff, but this not sort your initial list
# [Lucas](https://www.npmjs.com/~lucasmreis) say: Heyder Boladão
## I will help if you have any difficulty =)
Contact me by [github:heyderpd](https://github.com/heyderpd). I'll be glad to help you.
## Thanks for [npm~lucasmreis](https://www.npmjs.com/~lucasmreis)
```javascript
npm install --save acany
```
## Example:
```javascript
const acany = require('acany')
const list = [ 'hot coffee', 'chocolate', 'hot coffee with chocolate', 'coffee' ]
found = acany('coffee', list)
// found = [ 'coffee', 'hot coffee', 'hot coffee with chocolate' ]
found = acany('hot coffee', list)
// found = [ 'hot coffee', 'hot coffee with chocolate' ]
found = acany('hot chocolate', list)
// found = [ 'hot coffee with chocolate' ]
```
## Full Example:
```javascript
// acany(_NEED_, _LIST_, _LIMIT_)
const list = ['aaa', 'yxuu', 'abb', 'xbbc', 'xc', 'xx cc', 'bbc', 'ccc', 'xccc']
found = acany('xc', list)
// found = [ 'xc', 'xccc', 'xbbc', 'xx cc' ]
found = acany('x c', list)
// found = [ 'xbbc', 'xc', 'xx cc', 'xccc' ]
found = acany('x c', list, 2)
// found = [ 'xbbc', 'xc' ]
const boladao = require('boladao')
console.log('=>', boladao())
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc