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

findpattern

v0.0.47

Published

I am tired of this s**t

Downloads

10

Readme

THE ABCABC KILLER PATTERN

findpattern

I am really tired of this ... A lot of assessment for a job required to make stupid functions .... they ask to have the times of repetition of substrings like "ABCABC" ... and the same function need to report the length of same chars like 'CCCC'... Please, refuse test or assessment like that... not have any sense... especially if you looking for a position as front end... Should be a 'creative' position... what is the purpose of this test??? ... Know if you are crazy?, stupid?... so... it's my solution for you!

This is the most used test...

a relative link

My name is Dario Passariello... you can agree with me or not... but life is short....

INSTALL AND USE IT

npm i findpattern

or update:

npm i findpattern@latest

in the index (and only there):

import "findpattern"

or

require("findpattern");

EXAMPLE

So, I see that some test asking for a solution like this... enjoy! "The test ask to have count of groups pr count of word of subsequence"

findpattern.group = ( word ) => {

  let
  replace = word.match( /(.+)(?=.*?\1)/g ),
  pattern = new RegExp( replace , "g"),
  final = word.match( pattern );

  if( final ){
    return final.length;
  }else{
    return word.length;
  }

};

  // test it: 
  console.log( findpattern.group('abcabc') ); // -> 2 groups
  console.log( findpattern.group('cccc') ); // -> 4 chars
  

ANOTHER EXAMPLE

So, I see that some test asking for a solution like this... enjoy! "The test ask to have the length about on not repeated subsequence"

findpattern.countGroup = ( word ) => {
       
  const count = new Set(word);
  return count.size;

};

  // test it:
  console.log( findpattern.countGroup('abcabc') ); // -> 3
  console.log( findpattern.countGroup('cccc') ); // -> 1

PALINDROME

Here you another example for palindrome stuff. I hope that it's help you.


// example: findpattern.isSameA = ( 'cat','tac' ) -> true
// example: findpattern.isSameA = ( 'cat','act' ) -> true
// example: findpattern.isSameA = ( 'cat','tar' ) -> false
// or
// example: findpattern.isSameB = ( 'cat','tac' ) -> true
// example: findpattern.isSameB = ( 'cat','act' ) -> true
// example: findpattern.isSameB = ( 'cat','tar' ) -> false

//results are same but way are different

  // MY WAY
  findpattern.isSameA = ( a,b ) => {
    var first = a.split('').sort().join('');
    var second = b.split('').sort().join('');
    return first === second;
  };

  // test it:   
  console.log( "A_true", findpattern.isSameA("cat","tac") );
  console.log( "A_false", findpattern.isSameA("cat","rat") );

/****************************************************/

  // CHECK IF ARE PALINDROME
  findpattern.isSameB = ( a,b ) => {
    var re = /[\W_]/g;
    var lowStr = b.toLowerCase().replace(re, '');
    var revIt = lowStr.split('').reverse().join('');
    return a === revIt;
  };

  // test it:
  console.log( "B_true" , findpattern.isSameB( "cat", "tac") );
  console.log( "B_false" , findpattern.isSameB( "cat", "rat") );