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

filemantis-lib

v2.0.0

Published

FileMantis-Lib is a library of common Angular components, directives, pipes and so on that I use in my Electron projects. I don't expect anyone else will ever use this library as-is but you may find some of its ideas and techniques useful.

Downloads

7

Readme

FileMantis-Lib

FileMantis-Lib is a library of common Angular components, directives, pipes and so on that I use in my Electron projects. I don't expect anyone else will ever use this library as-is but you may find some of its ideas and techniques useful.

Installation

Just in case ...

npm install --save filemantis-lib

Components

import { LibModule } from 'filemantis-lib';

@NgModule({
  imports: [LibModule]
})

AnimatedRouterOutletComponent

Just use in place of <router-outlet> for a slide-in effect on route transitions.

  <lib-animated-router-outlet>
  </lib-animated-router-outlet>

DrawerContainerComponent and DrawerPanelComponent

Wrap content so that drawers of related content slide out on command from the top, right, bottom and/or left. The drawers are modal. Examples might be filters, preferences, CRUD support and the like.

<lib-drawer-container>

  <my-toolbar
    (showPrefs)="prefsDrawer.open()">
  </my-toolbar>
  ...
  <lib-drawer-panel
    #prefsDrawer
    position="right">
    ...
  </lib-drawer-panel>

</lib-drawer-container>

Markdown Component

Wrap arbitrary markdown, which will be converted to HTML as the component loads.

<lib-markdown>
# Hello, World!
</lib-markdown>  

Requires marked which might be loaded via .angular-cli.json.

"scripts": [
  "../node_modules/marked/marked.min.js"
],

Directives

Pipes

Decorators

@AutoUnsubscribe

Annotates a components so that any RxJS subscriptions are automatically unsubscribed when the component is destroyed.

import { AutoUnsubscribe } from 'filemantis-lib';
import { LifecycleComponent } from 'filemantis-lib';

@Component({...})
@AutoUnsubscribe()
export class MyComponent extends LifecycleComponent {

  private mySubscription: Subscription;
  private anotherSubscription: Subscription;

  constructor(...) {
    super();
    // sadly if you have a ctor you have to remember to call super!
  }

  // if non null when the component is destroyed, both will be unsubscribed
  // automatically -- no other action needed

}

@OnChange

Greatly simplifies ngOnChanges handling for @Input() fields, and is especially useful when those fields are supplied via the async pipe and you need to know when they've changed.

import { OnChange } from 'filemantis-lib';
import { LifecycleComponent } from 'filemantis-lib';

@Component({...})
export class MyComponent extends LifecycleComponent {

  @Input() a;
  @Input() b;

  constructor(...) {
    super();
    // sadly if you have a ctor you have to remember to call super!
  }

  @OnChange('a', 'b')
  myChanges(changedA: boolean, changedB: boolean) {
    // the name of this method is arbitrary
    // if multiple fields are coded, then it is called if EITHER changes
    // a boolean is passed for each so you can tell what changed
    if (this.a && this.changedA) { ... }
  }

}

Animations

It took me ages to get these right. Maybe I'm not so smart as I think! I do know that I hate DSLs. I think they're all a fraud. They pretend to be intuitive but there's no way to discern the API without examples, so I offer mine as models to use, discard or improve on.

inOutAnimation

Animates the changing contents of a container by fading in the new and fading out the old.

import { inOutAnimation } from 'filemantis-lib';

@Component({
  animations: [inOutAnimation()],
  ...
})
<div [@inOut]="... expression that identifies contents ...">
  ...
</div>

showHideAnimation

Shows the contents of a container by expanding it height to fit; hides the contents by shrinking its height to zero.

import { showHideAnimation } from 'filemantis-lib';

@Component({
  animations: [showHideAnimation()],
  ...
})
<div [@showHide]="expertMode? 'shown' : 'hidden'">
  ...
</div>

routeAnimation

Designed to be used by the AnimatedRouterOutletComponent as described above. It slides the contents of the old route out to the right, and the new in from the left.

Utilities

API Summary

export declare function debounce(func: any, wait?: number, immediate?: boolean): any;
export declare function deepCopy<T>(obj: T): T;
export declare function dump(data: Uint8Array, title: string, ebcdic?: boolean, color?: string): void;
export declare function isObjectEmpty(obj: any): boolean;
export declare function nextTick(f: any): void;
export declare function reverseMap(obj: any): any;
export declare function toHex(num: number, pad: number): string;

debounce

Very useful when you want to debounce but using Observable is impossible or inconvenient.

import { debounce } from 'filemantis-lib';

setup: any;

this.setup = debounce((...) => {
  ...
}, 250);

dump

Produces a nice, expandable dump of large objects (like Buffers) to the console.

Dump

nextTick

A semantic recasting of setTimeout(..., 0) when used (for example) In Angular to force rendering.

import { nextTick } from 'filemantis-lib';

nextTick((...) => {
  ...
});