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

@albertj97/testnpmmodules

v1.0.7

Published

examples of inheritance in object oriented programming.

Downloads

7

Readme

Eloquent JavaScript. Chapter 6: The Secret Life of Objects. Section Laying out a table

npm version

Build Status

Tarea

Se ha desarrollado la clase StretchCell que permite la representación de celdas de tipo "inner" y con un alto y ancho predefinido, para ello se ha creado una clase nueva que integra tres métodos.

  • Este método devuelve el máximo entre el valor que se le especifico como height o, en caso de ser este menor, un espacio de al menos la longitud del texto que represente la celda. Recordemos que inner es un objeto de tipo TCell.
 minHeight() {
    return Math.max(this.height, this.inner.minHeight());
  };
  • De igual forma pasaría con el método:
  minHeight() {
    return this.text.length;
  };
  • Por último se añadió el método draw para este tipo de celda, que lo que hace es llamar a la función draw de TCell, o el método draw del objeto que se le pase.
draw(width, height) {
    return this.inner.draw(width, height);
  };
  • Por último, en la modificación se añadió el siguiente código. Lo que hace es que cuando detecta que es un objeto de tipo StretchCell, se construye la celda StretchCell pasándole el nombre, el width y el height, en caso de que no lo sea, se reconoce el tipo de celda, y se le pasa el nombre para que se construya, pues la única celda que recive 3 parámetros es StretchCell
else if(value.constructor.name === 'Object'){
          if(value.type === 'StretchCell')
            return new Classes[value.type](new TCell(value.params[0]), value.params[1], value.params[2]);

          return new Classes[value.type](row.name);

Introduction

Example corresponds to the section Laying out a table of Chapter 6 The Secret Life of Objects, book Eloquent javaScript

Files:

ackage.json          - configuration and dependencies

gulpfile.js           - test: run mocha tests
                      - debugger: run the debbugger
                      - run: run the program

src                   - source folder
  input.json          - input file
  main.js             - main program
  Cell.js             - class cell
  RCell.js            - class rcell
  UnderlinedCell.js   - class underlinedcell
  s-cell.js           - class scell
  Table.js            - class table

test                  - mocha test
  test.js

Description

This example consist in a program that, given an array of arrays of table cells in json format, builds up a string that contains a nicely laid out table.

The src folder has the input file and the different classes, the main, all types of cell and the table. Also, in the test folder has the file the file with the developed tests.

Example of input used:

~/ejs-chapter-6-oop-KevMCh $ cat src/input.json

[
  {"name": "Kilimanjaro\nMontaña mágica", "height": 5895, "country": "Tanzania"},
  {"name": "Everest", "height": 8848, "country": "Nepal\nPaís lejano"},
  {"name": "Mount Fuji", "height": 3776, "country": "Japan"},
  {"name": "Mont Blanc", "height": 4808, "country": "Italy/France"},
  {"name": "Vaalserberg", "height": 323, "country": "Netherlands"},
  {"name": "Denali", "height": 6168, "country": "United States"},
  {"name": "Popocatepetl", "height": 5465, "country": "Mexico"}
]

If you want to run the code the different tasks is available in the gulp file.

  • Run the program with the debugger.
  • Run the program with the standard input.
  • Run the tests.

Final result:

~/ejs-chapter-6-oop-KevMCh $ gulp run
[12:42:05] Using gulpfile ~/Desktop/ejs-chapter-6-oop-KevMCh/gulpfile.js
[12:42:05] Starting 'run'...
name           height country      
-------------- ------ -------------
Kilimanjaro      5895 Tanzania     
Montaña mágica                     
Everest          8848 Nepal        
                      País lejano  
Mount Fuji       3776 Japan        
Mont Blanc       4808 Italy/France
Vaalserberg       323 Netherlands  
Denali           6168 United States
Popocatepetl     5465 Mexico       
[12:42:05] Finished 'run' after 84 ms