lazy-get-decorator
Advanced tools
Comparing version 1.2.2 to 2.0.0
{ | ||
"name": "lazy-get-decorator", | ||
"version": "1.2.2", | ||
"description": "Stub package for the soon-to-be-renamed \"typescript-lazy-get-decorator\"", | ||
"main": "index.js", | ||
"version": "2.0.0", | ||
"description": "Lazily evaluates a getter on an object and caches the returned value", | ||
"main": "LazyGetter.js", | ||
"browser": "_bundle/umd.js", | ||
"jsdelivr": "_bundle/umd.min.js", | ||
"fesm5": "_bundle/fesm5.js", | ||
"esm5": "_bundle/fesm5.js", | ||
"fesm2015": "_bundle/fesm2015.js", | ||
"esm2015": "_bundle/fesm5.js", | ||
"es2015": "esm2015/LazyGetter.js", | ||
"types": "LazyGetter.d.ts", | ||
"module": "_bundle/fesm5.js", | ||
"typings": "LazyGetter.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test:babel:legacy": "babel --config-file ./.babelrc.legacy -o test/LazyGetter.legacy.js test/LazyGetter.js", | ||
"test:babel:new": "babel --config-file ./.babelrc.new -o test/LazyGetter.new.js test/LazyGetter.js", | ||
"test:compile": "concurrently -n tsc:test \"tsc -p tsconfig.test.json\" \"npm:test:babel:*\"", | ||
"test": "nyc mocha --check-leaks --exit --full-trace test/LazyGetter.legacy.js test/LazyGetter.new.js test/LazyGetter.typescript.js", | ||
"pretest": "concurrently -n build:src,build:test,clean \"alo build --targets cjs\" \"npm run test:compile && ts-node pretest-postprocess.ts\" \"rimraf coverage\"", | ||
"build": "alo build", | ||
"lint": "alo tslint -p ./tsconfig.lib.json", | ||
"lint:fix": "npm run lint -- --fix" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Alorel/typescript-lazy-get-decorator.git" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"babel", | ||
"lazy get", | ||
"lazy getter", | ||
"lazy", | ||
"get", | ||
"getter", | ||
"cache", | ||
"memoise", | ||
"memoize", | ||
"decorator" | ||
], | ||
"author": { | ||
"name": "Arturas Molcanovas", | ||
"url": "https://alorel.github.io", | ||
"email": "a.molcanovas@gmail.com" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Alorel/typescript-lazy-get-decorator/issues" | ||
}, | ||
"homepage": "https://github.com/Alorel/typescript-lazy-get-decorator", | ||
"devDependencies": { | ||
"@alorel-personal/build-tools": "4.4.8", | ||
"@alorel-personal/conventional-changelog-alorel": "2.0.4", | ||
"@alorel-personal/semantic-release": "1.4.0", | ||
"@alorel-personal/tslint-rules": "4.1.1", | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.3.4", | ||
"@babel/plugin-proposal-class-properties": "~7.3.4", | ||
"@babel/plugin-proposal-decorators": "~7.3.0", | ||
"@semantic-release/changelog": "~3.0.0", | ||
"@semantic-release/exec": "~3.3.2", | ||
"@semantic-release/git": "~7.0.8", | ||
"@semantic-release/github": "^5.2.10", | ||
"@semantic-release/npm": "^5.0.2", | ||
"@types/chai": "^4.1.7", | ||
"@types/lodash": "~4.14.121", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "~11.10.4", | ||
"chai": "^4.2.0", | ||
"concurrently": "~4.1.0", | ||
"coveralls": "~3.0.3", | ||
"cross-spawn": "~6.0.5", | ||
"lodash": "~4.17.5", | ||
"mocha": "^6.0.2", | ||
"nyc": "~13.3.0", | ||
"rimraf": "~2.6.3", | ||
"semantic-release": "~15.13.3", | ||
"source-map-support": "^0.5.10", | ||
"ts-node": "^8.0.2", | ||
"tslib": "~1.9.0", | ||
"typescript": "^3.3.3" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -1,1 +0,89 @@ | ||
Stub package for the soon-to-be-renamed "typescript-proto-decorator" | ||
# Lazy Get decorator | ||
[![Build Status](https://travis-ci.org/Alorel/typescript-lazy-get-decorator.png?branch=2.0.0)](https://travis-ci.org/Alorel/typescript-lazy-get-decorator) | ||
[![Coverage Status](https://coveralls.io/repos/github/Alorel/typescript-lazy-get-decorator/badge.svg?branch=2.0.0)](https://coveralls.io/github/Alorel/typescript-lazy-get-decorator?branch=2.0.0) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/Alorel/typescript-lazy-get-decorator.svg)](https://greenkeeper.io/) | ||
[![NPM](https://nodei.co/npm/lazy-get-decorator.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/lazy-get-decorator) | ||
Previously known as [typescript-lazy-get-decorator](https://www.npmjs.com/package/lazy-get-decorator). | ||
# Compatibility | ||
- Typescript - full | ||
- Spec-compliant decorator proposal - full | ||
- Babel (current proposal) - full | ||
- Babel (legacy) - full | ||
# API | ||
```typescript | ||
/** | ||
* Evaluate the getter function and cache the result | ||
* @param {boolean} [setProto=false] Set the value on the class prototype as well. Only applies to non-static getters. | ||
* @param {boolean} [makeNonConfigurable=false] Set to true to make the resolved property non-configurable | ||
* @return {(target: any, key: string, descriptor: PropertyDescriptor) => void} A Typescript decorator function | ||
*/ | ||
function LazyGetter(setProto: boolean = false, makeNonConfigurable = false) {} | ||
``` | ||
# Usage | ||
```typescript | ||
import {LazyGetter} from 'lazy-get-decorator'; | ||
class AClass { | ||
@LazyGetter() | ||
get lazyNoProto(): string { | ||
console.log('Evaluating lazyNoProto'); | ||
return 'lazyNoProtoValue'; | ||
} | ||
@LazyGetter(true) | ||
get lazyWithProto(): string { | ||
console.log('Evaluating lazyWithProto'); | ||
return 'lazyWithProtoValue'; | ||
} | ||
} | ||
const inst1 = new AClass(); | ||
console.log('==== inst 1 ====\n'); | ||
console.log(inst1.lazyNoProto); | ||
console.log(inst1.lazyNoProto); | ||
console.log(inst1.lazyWithProto); | ||
console.log(inst1.lazyWithProto); | ||
const inst2 = new AClass(); | ||
console.log('\n\n==== inst 2 ====\n'); | ||
console.log(inst2.lazyNoProto); | ||
console.log(inst2.lazyNoProto); | ||
console.log(inst2.lazyWithProto); | ||
console.log(inst2.lazyWithProto); | ||
``` | ||
Output: | ||
==== inst 1 ==== | ||
Evaluating lazyNoProto | ||
lazyNoProtoValue | ||
lazyNoProtoValue | ||
Evaluating lazyWithProto | ||
lazyWithProtoValue | ||
lazyWithProtoValue | ||
==== inst 2 ==== | ||
Evaluating lazyNoProto | ||
lazyNoProtoValue | ||
lazyNoProtoValue | ||
lazyWithProtoValue | ||
lazyWithProtoValue |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
49850
14
379
0
0
90
0
30