Comments (4)
Can you explain a use case where you would accidentally set one of these properties such as json
? I canβt think of why one would ever try to do that in the first place?
from r2.
I forgot about this issue completely :P What I meant is, that json
was just an example. There are several read-only fields that are being protected from being set (with failSet
), but when such a failure happens, the log message does not indicate what did you try to set. The purposed change would now look like so:
const failSet = way => () => throw new Error('Cannot set read-only property R2.${way}') // <-- see this
const resolveResWith = way => resp => resp.clone()[way]()
/* formData isn't implemented in the shim yet */
const ways = ['json', 'text', 'arrayBuffer', 'blob', 'formData']
ways.forEach(way =>
Object.defineProperty(this, way, {
get: () => this.response.then(resolveResWith(way)),
set: failSet(way) // <-- fail set will tell you what read-only property you tried to change
})
)
from r2.
gotcha, thanks for following up after all this time
from r2.
@gr2m got it
I'm not using the library now, I don't even remember when I had to use it, but I'm glad that good design decisions are taken nonetheless. Keep it up
from r2.
Related Issues (20)
- A strange behavior of .json HOT 5
- Issues with binary files HOT 12
- Enable promise dependency injection (just like node-fetch) HOT 4
- No package description HOT 3
- r2 doesn't have formData post?
- Encoding parameter HOT 1
- [TS] r2 typescript declaration file HOT 4
- An in-range update of semantic-release is breaking the build π¨ HOT 2
- Assuming all JSON payloads are application/json is wrong HOT 1
- String stream support
- An in-range update of semantic-release is breaking the build π¨ HOT 2
- r2.post not working vs fetch HOT 1
- The automated release is failing π¨ HOT 5
- Ilegal http header
- An in-range update of browserify is breaking the build π¨ HOT 2
- Uri with ':' inside it are misinterpreted.
- DeprecationWarning: Buffer() is deprecated due to security and usability issues
- Responsible disclosure policy
- Vulnerability - Upgrade node-fetch version from 2.6.5 to 2.6.7, 3.1.1
- Potential security vulnerabili
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r2.