mirror of
				https://github.com/AmberGraceRblx/luau-promise.git
				synced 2025-10-31 18:39:27 +00:00 
			
		
		
		
	Convert Promise.Status to be a userdata with __tostring
This commit is contained in:
		
							parent
							
								
									8dd394cccd
								
							
						
					
					
						commit
						d8c3bb9264
					
				
					 1 changed files with 15 additions and 3 deletions
				
			
		
							
								
								
									
										18
									
								
								lib/init.lua
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								lib/init.lua
									
									
									
									
									
								
							|  | @ -62,14 +62,26 @@ local function isEmpty(t) | ||||||
| 	return next(t) == nil | 	return next(t) == nil | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | local function createSymbol(name) | ||||||
|  | 	assert(type(name) == "string", "createSymbol requires `name` to be a string.") | ||||||
|  | 
 | ||||||
|  | 	local symbol = newproxy(true) | ||||||
|  | 
 | ||||||
|  | 	getmetatable(symbol).__tostring = function() | ||||||
|  | 		return ("Symbol(%s)"):format(name) | ||||||
|  | 	end | ||||||
|  | 
 | ||||||
|  | 	return symbol | ||||||
|  | end | ||||||
|  | 
 | ||||||
| local Promise = {} | local Promise = {} | ||||||
| Promise.prototype = {} | Promise.prototype = {} | ||||||
| Promise.__index = Promise.prototype | Promise.__index = Promise.prototype | ||||||
| 
 | 
 | ||||||
| Promise.Status = { | Promise.Status = { | ||||||
| 	Started = "Started", | 	Started = createSymbol("Started"), | ||||||
| 	Resolved = "Resolved", | 	Resolved = createSymbol("Resolved"), | ||||||
| 	Rejected = "Rejected", | 	Rejected = createSymbol("Rejected"), | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| --[[ | --[[ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue